接口使用场景等说明:本接口主要用于从淘宝联盟2022年下半年新推出的动态字符串ID中获取手淘的数字ID。
比如淘宝联盟商品字符型动态ID“PKxJMYnNYjt3tg3vdWfDPwUPt6-0Aoqb2TBYQbp808ixd”,转成 686631849859 数字商品ID。
接口适用于淘客在有些场景下使用。
| 环境 | http 地址 | https 地址 |
|---|---|---|
| 正式环境 | http://api.veapi.cn/tbk/gettbnumid | 暂无 |
| 参数名称 | 参数类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| vekey | String | 是 | V123M56 | 公共参数,接口秘钥,请在会员中心获取 |
| stringid | String | 是 | wUPt6-0Aoqb | 淘宝联盟aaaa-bbbb段的新字符型ID。 |
| pid | String | 否 | mm_11_22_33 | 请在会员中心用您的联盟号授权,并提供授权联盟号的PID参数,转换时需要用sessionkey验证字符ID有效性。如果没有在会员中心——授权管理下设置了默认PID,则本参数必传。 |
| relation_id | String | 否 | 655655121 | 渠道ID,如果不了解渠道ID,请参考这里 |
GET/POST http://api.veapi.cn/tbk/gettbnumid?vekey=xxx&stringid=aaa-bbbb&pid=mm_12313212_23211422_9556632231
$api="http://api.veapi.cn/tbk/gettbnumid?vekey=xxx&stringid=aaa-bbbb&pid=mm_12313212_23211422_9556632231"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api); //curl_setopt($ch, CURLOPT_POST, true); //POST方式时启用 //curl_setopt($ch, CURLOPT_POSTFIELDS, $postData ); //POST方式时传参 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //如果使用https请启用 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //如果使用https请启用 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true ); //返回数据流,不直接输出 curl_setopt($ch, CURLOPT_ENCODING, 'gzip'); //使用gzip压缩传输让访问更快 curl_setopt($ch, CURLOPT_TIMEOUT, 6); //允许执行的最长秒数。这里设定6S curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); $result = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); echo $result; //返回值
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpRequest;
public class testGetParam {
public static void main(String[] args) {
// API网址
String url = "http://api.veapi.cn/tbk/gettbnumid?vekey=xxx&stringid=aaa-bbbb&pid=mm_12313212_23211422_9556632231";
// JDK 8u111版本后,若目标页面为HTTPS协议,请启用proxy用户密码鉴权
//System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
// 发送请求
String result = HttpRequest.get(url)
.timeout(10000)//设置超时,毫秒
.execute().body();
System.out.println(result);
}
}
import requests # 要访问的API网页 target_url = "http://api.veapi.cn/tbk/gettbnumid?vekey=xxx&stringid=aaa-bbbb&pid=mm_12313212_23211422_9556632231" # 发送请求 response = requests.get(target_url) # 获取页面内容 if response.status_code == 200: print response.text
| 参数名称 | 参数类型 | 示例值 | 描述 |
|---|---|---|---|
| itemid | String | 684228041169 | 淘宝天猫的商品数字ID |
{ "error": "0", "msg": "动态ID解析成功,取得数字ID", "data": { "itemid": "684228041169" }, "request_id": "xCZYVZn" }