Пример #1
0
 function get_j($arr)
 {
     global $_G;
     include_once ROOT_PATH . 'top/tbk/TbkItemGetRequest.php';
     $req = new TbkItemGetRequest();
     $req->setFields("num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url");
     if ($arr['keyword']) {
         $req->setQ($arr['keyword']);
     }
     if ($arr['cid']) {
         $req->setCat($arr['cat']);
     }
     if ($arr['area']) {
         $req->setItemloc($arr['itemloc']);
     }
     if ($arr['sort']) {
         if ($arr['sort'] == 'default') {
             $req->setSort('total_sales_desc');
         } else {
             $req->setSort($arr['sort']);
         }
     }
     if ($arr['mall_item'] == 'true') {
         $req->setIsTmall(true);
     }
     if ($arr['page_no']) {
         $req->setPageNo($arr['page_no']);
     }
     $req->setPageSize(40);
     if ($arr['start_price']) {
         $req->setStartPrice($arr['start_price']);
     }
     //折扣价范围下限
     if ($arr['end_price']) {
         $req->setEndPrice($arr['end_price']);
     }
     //折扣价范围上限
     if ($arr['start_commission_rate']) {
         $req->setStartTkRate($arr['start_commission_rate'] * 100);
     }
     //淘客佣金比率上限
     if ($arr['end_commission_rate']) {
         $req->setEndTkRate($arr['end_commission_rate'] * 100);
     }
     //淘客佣金比率上限
     //以下四个条件,淘客API中没有
     //if($arr['startcredit'])$req->setQ($arr['keyword']);
     //if($arr['endcredit'])$req->setQ($arr['keyword']);
     //if($arr['start_commission_num'])$req->setQ($arr['keyword']);
     //if($arr['end_commission_num'])$req->setQ($arr['keyword']);
     $resp = $_G['TOP']->execute($req);
     top_check_error($resp, $this->show_error);
     $this->parse($resp);
     $rt = array();
     $rt['count'] = $resp->total_results;
     $rt['goods'] = $this->goods_list;
     return $rt;
 }
Пример #2
0
 function get($arr)
 {
     global $_G;
     include_once ROOT_PATH . 'top/tbk/TbkItemGetRequest.php';
     $req = new TbkItemGetRequest();
     $req->setFields("num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url");
     foreach ($arr as $k => $v) {
         if ($v) {
             $req->putOtherTextParam($k, $v);
         }
     }
     $resp = $_G['TOP']->execute($req);
     top_check_error($resp, 1);
     $list = $this->parse($resp);
     return $list;
 }
Пример #3
0
 public function getItem($q, $cat = '', $isTmall = FALSE, $startPrice = '', $endPrice = '', $startTkRate = '', $endTkRate = '', $sort = 'tk_rate_des', $pageNO = 1, $pageSize = 30, $platForm = 1, $loc = '')
 {
     if (empty($q) && empty($cat)) {
         $this->error = "code:-1001;q查询词和cat分类id不能同为空";
         return -1001;
     }
     $req = new TbkItemGetRequest();
     $req->setFields("num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url,click_url");
     if (!empty($q)) {
         $req->setQ($q);
     }
     if (!empty($cat)) {
         $req->setCat($cat);
     }
     if (!empty($loc)) {
         $req->setItemloc($loc);
     }
     $req->setSort($sort);
     $req->setIsTmall($isTmall);
     $req->setIsOverseas("false");
     if (!empty($startPrice)) {
         $req->setStartPrice($startPrice);
     }
     if (!empty($endPrice)) {
         $req->setEndPrice($endPrice);
     }
     if (!empty($startTkRate)) {
         $req->setStartTkRate($startTkRate);
     }
     if (!empty($endTkRate)) {
         $req->setEndTkRate($endTkRate);
     }
     $req->setPlatform($platForm);
     $req->setPageNo($pageNO);
     $req->setPageSize($pageSize);
     $goodsList = '';
     $resp = $this->c->execute($req);
     if (!empty($resp->results->n_tbk_item)) {
         $items = $resp->results->n_tbk_item;
         foreach ($items as $row) {
             $goods['item_url'] = $row->item_url;
             $goods['pic_url'] = $row->pict_url;
             $goods['price'] = $row->reserve_price;
             $goods['discount_price'] = $row->zk_final_price;
             $goods['click_url'] = $row->click_url;
             $goods['title'] = $row->title;
             $goods['item_url'] = $row->item_url;
             $goods['num_iid'] = $row->num_iid;
             if ($isTmall) {
                 $goods['goods_type'] = 'tmall';
             } else {
                 $goods['goods_type'] = 'taobao';
             }
             $goodsList[] = $goods;
         }
     }
     return $goodsList;
 }
Пример #4
0
//$req->setFields("open_iid,title,nick,pic_url,price,commission,commission_rate,commission_num,commission_volume,seller_credit_score,item_location,volume,coupon_price,coupon_rate,coupon_start_time,coupon_end_time,shop_type,click_url");
//$req->setKeyword("女装");
//$req->setPageNo("1");
//$req->setPageSize("40");
//$req->setShopType("all");
//$req->setSort("default");
//$req->setStartCommissionNum("100");
//$req->setStartCommissionRate("1234");
//$req->setStartCommissionVolume("100");
//$req->setStartCouponRate("7000");
//$req->setStartCredit("3diamond");
//$req->setStartVolume("100");
//$resp = $c->execute($req);
//echo '<pre>';
//print_r($resp);
$req = new TbkItemGetRequest();
$req->setFields("num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url");
$req->setQ("女装");
//$req->setCat("16,18");
$req->setItemloc("杭州");
$req->setSort("tk_rate_des");
//$req->setIsTmall("false");
$req->setIsOverseas("false");
//$req->setStartPrice("10");
//$req->setEndPrice("10");
//$req->setStartTkRate("123");
//$req->setEndTkRate("123");
$req->setPlatform("1");
$req->setPageNo("1");
$req->setPageSize("20");
$resp = $c->execute($req);
Пример #5
0
 public function caijiApi()
 {
     $p = $_GET;
     $count = 0;
     Vendor('tbk.TopSdk');
     $c = new TopClient();
     $c->appkey = $this->setting['tb_api_key'];
     $c->secretKey = $this->setting['tb_api_secret'];
     $req = new TbkItemGetRequest();
     $req->setFields("num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url");
     $p['keyword'] && $req->setQ($p['keyword']);
     $p['cid'] && $req->setCat($p['cid']);
     $p['start_price'] > 0 && $req->setStartPrice($p['start_price']);
     $p['end_price'] > 0 && $req->setEndPrice($p['end_price']);
     $p['sort'] && $req->setSort($p['sort']);
     $p['start_commissionRate'] > 0 && $req->setStartTkRate($p['start_commissionRate']);
     $p['end_commissionRate'] > 0 && $req->setEndTkRate($p['end_commissionRate']);
     $p['mall_item'] && $req->setIsTmall("true");
     $req->setPageSize(100);
     $resp = $c->execute($req);
     $a = $resp->results->n_tbk_item;
     foreach ($a as $val) {
         if ($count >= $p['num']) {
             break;
         }
         $goods = array('title' => $val->title, 'num_iid' => $val->num_iid, 'item_url' => $val->item_url, 'price' => $val->reserve_price, 'discount_price' => $val->zk_final_price, 'goods_type' => $val->user_type ? 'tmall' : 'taobao', 'pic_url' => $val->pict_url, 'provcity' => $val->provcity, 'add_uid' => $this->my['uid'], 'add_uname' => $this->my['uname'], 'ctime' => TIME, 'sort_id' => $p['sort_id'], 'state' => $p['state'] ? 1 : 0);
         $count++;
         $goods_list[] = $goods;
     }
     echo json_encode(array('data' => $goods_list, 'count' => $count));
 }
Пример #6
0
/**
 * 获取查询的记录信息
 */
function api_data_get($client, $category, $isTMallStr, $page, $pageSize)
{
    $req = new TbkItemGetRequest();
    $req->setFields("num_iid,title,pict_url,small_images,reserve_price,zk_final_price,item_url,user_type");
    $req->setQ($category);
    $pageStr = '' . $page;
    $pageSizeStr = '' . $pageSize;
    //	$req->setCat("16,18");
    // $req->setItemloc("杭州");
    $req->setSort("tk_rate_des");
    $req->setIsTmall($isTMallStr);
    // $req->setIsOverseas("false");
    $req->setStartPrice("9");
    $req->setEndPrice("10");
    // $req->setStartTkRate("123");
    // $req->setEndTkRate("123");
    // $req->setPlatform("1");
    $req->setPageNo($pageStr);
    $req->setPageSize($pageSizeStr);
    $resp = $client->execute($req);
    return $resp;
}