1.获取商品类别信息:
include "../lib/TopSdk.php";//导入api
$c = new TopClient;
$c->appkey = "21302640";
$c->secretKey = "d4ff79905b581e369ccf0360a94c6b40";
$req = new ItemcatsGetRequest;
$req->setFields("cid,parent_cid,name,is_parent");
$req->setParentCid(1801);
$resp = $c->execute($req);
$ob = new ItemcatsGetRequest;
$ob->setFields("cid,parent_cid,name,is_parent");
$ob->setParentCid(50010788);
$obp = $c->execute($ob);//以上是根据父级的分类ID获取子集的全部分类信息,想输出信息或者调用时如下所示:
<select>
<option value="0">所有分类</option>
<?php
foreach($resp as $item)
{ foreach($item as $key)
{
?>
<option value="<?php echo $key->cid;?>"><?php echo $key->name;?></option>
<?php }}?>
</select>
//直接用print_r输出即可
2.根据分类ID获取该类别下的全部商品:
$c = new TopClient;
$c->appkey = "21302640";
$c->secretKey ="d4ff79905b581e369ccf0360a94c6b40";
$req = new TaobaokeItemsGetRequest;
$req->setFields("num_iid,title,nick,pic_url,price,coupon_price,click_url,commission,commission_rate,commission_num,commission_volume,shop_click_url,seller_credit_score,item_location,volume");
$req->setCid(50010788);
$resp = $c->execute($req);
3.获取折扣商品
$c = new TopClient;
$c->appkey = "21302640";
$c->secretKey = "d4ff79905b581e369ccf0360a94c6b40";
$req = new TaobaokeItemsCouponGetRequest;
$req->setCid($cid);
$req->setFields("num_iid,title,nick,pic_url,price,click_url,commission,commission_rate,commission_num,commission_volume,shop_click_url,seller_credit_score,item_location,volume,coupon_price,coupon_rate,coupon_start_time,coupon_end_time,shop_type");
$resp = $c->execute($req);