博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php调用拼多多的接口
阅读量:4519 次
发布时间:2019-06-08

本文共 1503 字,大约阅读时间需要 5 分钟。

 

/*拼多多API类*/

class CeshiController extends Controller
{
private $client_id = 'client_id'; // 你的client_id
private $client_secret = 'client_secret'; // 你的client_secret
private function GetPDDApi($apiType, $param)
{
$appInfo = zfun::f_getset('pdd_client_id,pdd_client_secret');
$param['client_id'] = $this->client_id;
$param['type'] = $apiType;
$param['data_type'] = 'JSON';
$param['timestamp'] = self::getMillisecond();
ksort($param); // 排序
$str = ''; // 拼接的字符串
foreach ($param as $k => $v) $str .= $k . $v;
$sign = strtoupper(md5($this->client_secret. $str . $this->client_secret)); // 生成签名 MD5加密转大写
$param['sign'] = $sign;
$url = 'http://gw-api.pinduoduo.com/api/router';
// return self::curl_post($url, $param);
$data=self::curl_post($url, $param);
}

// post请求

private static function curl_post($url, $curlPost)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}

// 获取13位时间戳

private static function getMillisecond()
{
list($t1, $t2) = explode(' ', microtime());
return sprintf('%.0f', (floatval($t1) + floatval($t2)) * 1000);
}
public function ceshi(){
return "1111";
}
}

转载于:https://www.cnblogs.com/caeserzxz/p/8760242.html

你可能感兴趣的文章
运行期异常与编译期异常区别
查看>>
STM32使用注意事项
查看>>
第十万零二个素数
查看>>
前端笔记之Vue(七)Vue-router&axios&Vue插件&Mock.js&cookie|session&加密
查看>>
【C++】C++运行环境的搭建
查看>>
Kotlin之定义函数
查看>>
Dart泛型
查看>>
windowsclient开发--duilib显示html
查看>>
关于离职证明和竞业条款
查看>>
库存管理系统
查看>>
BZOJ 2809 APIO 2012 dispatching 平衡树启示式合并
查看>>
mavan和idea的搭建,很好的一篇文章
查看>>
springboot访问项目中某个module的图片(服务器拿不到)
查看>>
[P1329] 数列
查看>>
Research on How Tradeshow Magician Works
查看>>
LINUX 配置网络
查看>>
一个不错的git资源站点
查看>>
收缩数据库
查看>>
01_8_session
查看>>
HDU 2054 A==B? 大数
查看>>