Home > php教程 > php手册 > php版淘宝网查询商品接口代码示例

php版淘宝网查询商品接口代码示例

WBOY
Release: 2016-06-06 20:21:32
Original
1348 people have browsed it

本文来给大家介绍一个php版淘宝网查询商品接口代码的例子,下面要改成你的信息的在代码后面都有说明了,需要的朋友可以参考下

本文来给大家介绍一个php版淘宝网查询商品接口代码的例子,下面要改成你的信息的在代码后面都有说明了,同时sdk包我们也要官方下载。

下载SDK后直接引用包,并创建如下的类,,并运行之,即完成了调用接口(taobao.user.seller.get)的过程(调用接口说明可见下载的SDK)
说明:
    TopClient为调用SDK的实例化类
    UserSellerGetRequest为API的请求参数封装类

注:该接口是在沙箱环境下调用,获取的数据,也是沙箱中数据。若要获取线上环境,请填写自己创建应用获取过来的appkey,appsecret,并更改调用接口的环境地址,同时修改nick为淘宝登陆名。

下载SDK包解压后与该文件放在同一目录下。

复制代码 代码如下:

header("Content-type: text/html; charset=utf-8");
include "TopSdk.php";
//将下载SDK解压后top里的TopClient.php第8行$gatewayUrl的值改为沙箱地址:,
//正式环境时需要将该地址设置为:

//实例化TopClient类
$c = new TopClient;
$c->appkey = "xxxxxx"; //换成你的appkey
$c->secretKey = "xxxxxxxx"; //换成你的secretKey
$sessionkey= "xxxxxx";   //如沙箱测试帐号sandbox_c_1授权后得到的sessionkey
//实例化具体API对应的Request类
$req = new UserSellerGetRequest;
$req->setFields("nick,user_id,type");
//$req->setNick("sandbox_c_1");

//执行API请求并打印结果
$resp = $c->execute($req,$sessionkey);
echo "result:";
print_r($resp);
?>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template