1、接口:http://pub.alimama.com/common/code/getAuctionCode.json?auctionid=39524112051&adzoneid=73654400&siteid=21940266&scenes=1&t=1489238018764&_tb_token_=qO2Nj1Sk4Rq&pvid=10_122.233.43.77_1118_1489238002348
2、参数说明:
接口明细
请求地址:http://pub.alimama.com/common/code/getAuctionCode.json
请求方法:GET
请求参数:
auctionid 要转换的商品Id
siteid 推广站点id
adzoneid 推广位id
scenes 设置为1固定值,含义未知
t 时间戳
响应结果部分参数:
taoToken 淘口令
qrCodeUrl 二维码推广地址
clickUrl 链接推广地址
couponLinkTaoToken 领券淘口令
couponLink 领券链接地址
shortLinkUrl 短链接地址
注意点:
该接口需要淘客登陆后使用!
贴上cURL的方法(PHP版本):
$ch = curl_init();
$start_time = '2018-10-31';
$end_time = '2018-11-06';
$timesamp = getMillisecond(); //13位时间戳
$url = "http://pub.alimama.com/common/code/getAuctionCode.json?auctionid=39524112051&adzoneid=73654400&siteid=21940266&scenes=1&t=1489238018764&_tb_token_=qO2Nj1Sk4Rq&pvid=10_122.233.43.77_1118_1489238002348";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$headers = array();//自定义header
$headers[] = 'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8'; $headers[] = 'Accept-Encoding:gzip, deflate';
$headers[] = 'Accept-Language:zh-CN,zh;q=0.9';
$headers[] = 'Cache-Control:no-cache';
$headers[] = 'Cookie:t=660a365e8c6eaf42590214ffd1502684; cna=loM0FPWBlSICAXVZSgPPKrKd; account-path-guide-s1=true; 16914566_yxjh-filter-1=true; 221090120_yxjh-filter-1=true; 51464418_yxjh-filter-1=true; undefined_yxjh-filter-1=true; cookie2=13162fab18b19a6dd33db27d1d106783; v=0; _tb_token_=5eeeb30e9f0e3; alimamapwag=TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgNi4xOyBXT1c2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzYzLjAuMzIzOS4yNiBTYWZhcmkvNTM3LjM2IENvcmUvMS42My42Nzc2LjQwMCBRUUJyb3dzZXIvMTAuMy4yNTc3LjQwMA%3D%3D; cookie32=31b6d086e42d83b842363fc958607b9a; alimamapw=FgdSAV0GBlYOU1tbDzkHBwIMVARUBVVRBFMAVwAFB1MEBVULAFRUAwMHAABcBw%3D%3D; cookie31=NTE0NjQ0MTgsdGIxMzg1NzI3Njg4OCxqaWFjaHVudGFvQDEzOS5jb20sVEI%3D; login=VFC%2FuZ9ayeYq2g%3D%3D; isg=BM_PEmUTyCfi1swEcrERX-1sS2MZXDw1CQ7Q_eHcaz5FsO-y6cSzZs2htqCryPuO; JSESSIONID=8BEEF09F25370FB3AB88CEF5CFB0086A; apushcdef74c54332d7c95a8e1b72ed8705cd=%7B%22ts%22%3A1541492875098%2C%22parentId%22%3A1541486399635%7D';
$headers[] = 'Host:pub.alimama.com';
$headers[] = 'Pragma:no-cache';
$headers[] = 'Proxy-Connection:keep-alive';
$headers[] = 'Upgrade-Insecure-Requests:1';
$headers[] = 'Referer:http://pub.alimama.com/common/code/getAuctionCode.json?auctionid=39524112051&adzoneid=73654400&siteid=21940266&scenes=1&t=1489238018764&_tb_token_=qO2Nj1Sk4Rq&pvid=10_122.233.43.77_1118_1489238002348';
$headers[] = 'user-agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.26 Safari/537.36 Core/1.63.6776.400 QQBrowser/10.3.2577.400'; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // 执行一个curl会话
$contents = curl_exec($ch); // 返回一个保护当前会话最近一次错误的字符串
$error = curl_error($ch); if ($error) { echo 'Error: ' . $error; } // 关闭一个curl会话
curl_close($ch);
$contents=mb_convert_encoding($contents, 'UTF-8', 'UTF-8,GBK,GB2312,BIG5');
p($contents);
tips:如何保证登录时效,我这边是隔一段时间请求一次,保证登录状态。
网友评论