去评论
dz插件网

根据关键词调用淘宝相关商品API接口(基于大淘客)

婷姐
2025/01/04 08:57:11
根据关键词调用淘宝相关商品API接口(基于大淘客)
1,不用说了先下载他们的SDK包
2,以帝国CMS为例,代码如下:
  1. <?phprequire('../../class/connect.php');require('../../class/db_sql.php');include 'vendor/autoload.php';//引入大淘客自动加载类$link=db_connect();$empire=new mysqlquery();$keyWords=RepPostVar($_REQUEST['msg']);$keyWords=esub($keyWords,6);$appkey = $public_r['add_dataokeappkey']; // 替换为你的大淘客App Key$appsecret =$public_r['add_dataokeappsecret']; // 替换为你的大淘客App Secret$client = new GetTipList();$client->setAppKey($appkey);$client->setAppSecret($appsecret);$client->setVersion('v3.0.0');$method = 'get'; $url="https://openapi.dataoke.com/api/goods/list-super-goods";// 根据关键词匹配淘宝商品$params = ['type' => 0,'pageId' => 1,'pageSize' => 10,'keyWords' => $keyWords,];$result = $client->doRequest($method, $url, $params);$resultt=json_decode($result);$resu=$resultt->data;$array = (array)$resu;$shop = $array['list'];if(empty($shop)){$url = "https://openapi.dataoke.com/api/goods/super-discount-goods"; // API的URL,返回最新的折上再折的商品合集$params = ['pageId' =>1,'pageSize' => 10,];$result = $client->doRequest($method, $url, $params);        $resultt=json_decode($result);$resu=$resultt->data;$array = (array)$resu;$shop =$array['list'];}$json = json_encode($shop);echo $json;
至于发起AJAX请求请自行脑补。