Exemplo n.º 1
0
 /**
  * 淘宝客店铺搜索
  *
  */
 public function getTaobaokeShops(array $params)
 {
     require_once 'Request/TaobaokeShopsGetRequest.php';
     $req = new TaobaokeShopsGetRequest();
     $req->setFields("user_id, click_url, shop_title, commission_rate, seller_credit, shop_type, auction_count, total_auction");
     $req->setCid($params['cid']);
     $req->setKeyword($params['kw']);
     $req->setPageNo($params['page']);
     $req->setPageSize(40);
     $req->setNick($this->_taobao_nick);
     $req->setPid($this->_taobao_pid);
     return $resp = $this->_topClient->execute($req);
 }
Exemplo n.º 2
0
function xt_taobaoke_shops_search($params)
{
    $app = xt_taobao_is_ready();
    if (!$app) {
        return new WP_Error('系统错误', '尚未配置淘宝开放平台!');
    }
    $params = _xt_taobaoke_shops_search_params($params);
    if (empty($params['keyword']) && (empty($params['cid']) || intval($params['cid']) == 0)) {
        return new WP_Error('业务错误', '参数不完整,必须指定搜索关键词或搜索分类!');
    }
    include_once XT_PLUGIN_DIR . '/xt-core/sdks/taobao/RequestCheckUtil.php';
    include_once XT_PLUGIN_DIR . '/xt-core/sdks/taobao/TopClient.php';
    include_once XT_PLUGIN_DIR . '/xt-core/sdks/taobao/request/TaobaokeShopsGetRequest.php';
    $client = new TopClient();
    $client->format = 'json';
    $client->appkey = $app['appKey'];
    $client->secretKey = $app['appSecret'];
    $req = new TaobaokeShopsGetRequest();
    $req->setFields($params['fields']);
    if (!empty($params['keyword'])) {
        $req->setKeyword($params['keyword']);
    }
    if (!empty($params['cid']) && intval($params['cid']) > 0) {
        $req->setCid(intval($params['cid']));
    }
    if (!empty($params['start_credit']) && intval($params['start_credit']) > 0) {
        $req->setStartCredit(xt_taobao_credit(absint($params['start_credit'])));
    }
    if (!empty($params['end_credit']) && intval($params['end_credit']) > 0) {
        $req->setEndCredit(xt_taobao_credit(absint($params['end_credit'])));
    }
    if (!empty($params['start_commissionrate']) && intval($params['start_commissionrate']) > 0) {
        $req->setStartCommissionrate($params['start_commissionrate']);
    }
    if (!empty($params['end_commissionrate']) && intval($params['end_commissionrate']) > 0) {
        $req->setEndCommissionrate($params['end_commissionrate']);
    }
    if (!empty($params['start_auctioncount']) && intval($params['start_auctioncount']) > 0) {
        $req->setStartAuctioncount($params['start_auctioncount']);
    }
    if (!empty($params['end_auctioncount']) && intval($params['end_auctioncount']) > 0) {
        $req->setEndAuctioncount($params['end_auctioncount']);
    }
    if (!empty($params['start_totalaction']) && intval($params['start_totalaction']) > 0) {
        $req->setStartTotalaction($params['start_totalaction']);
    }
    if (!empty($params['end_totalaction']) && intval($params['end_totalaction']) > 0) {
        $req->setEndTotalaction($params['end_totalaction']);
    }
    $req->setOnlyMall($params['only_mall'] ? "true" : "false");
    //    if (!empty($params['sort_field']))
    //        $req->setSortField($params['sort_field']);
    //    if (!empty($params['sort_type'])) {
    //        $req->setSortType($params['sort_type']);
    //    }
    $req->setSortField('total_auction');
    $req->setSortType('desc');
    if (!empty($params['page_no'])) {
        $req->setPageNo(intval($params['page_no']));
    }
    if (!empty($params['page_size'])) {
        $req->setPageSize(intval($params['page_size']));
    }
    $req->setOuterCode(xt_outercode());
    $resp = $client->execute($req);
    if (isset($resp->sub_code)) {
        return new WP_Error($resp->sub_code > 0 ? $resp->sub_code : '500', $resp->sub_msg);
    } elseif (isset($resp->code)) {
        return new WP_Error($resp->code > 0 ? $resp->code : '500', $resp->msg);
    }
    if (isset($resp->taobaoke_shops) && isset($resp->taobaoke_shops->taobaoke_shop)) {
        return array('shops' => $resp->taobaoke_shops->taobaoke_shop, 'total' => $resp->total_results);
    }
    return array('shops' => array(), 'total' => 0);
}