yumufeng / jd-union-sdk Goto Github PK
View Code? Open in Web Editor NEW京东联盟SDK,支持swoole和fpm两种模式
京东联盟SDK,支持swoole和fpm两种模式
https://union.jd.com/openplatform/api/10419 jd.union.open.order.query 即将下线(听闻将于2021年2月5日下线)
https://union.jd.com/openplatform/api/12707 jd.union.open.order.row.query 这是新的接口
`/**
* JdGateWay constructor.
* @param array $config
* @param JdFatory $jdFatory
*/
public function __construct(array $config, JdFatory $jdFatory)
{
$this->appkey = $config['appkey'];
$this->appSecret = $config['appSecret'];
$this->apithId = isset($config['apithId']) ? $config['apithId'] : '';
$this->apithKey = isset($config['apithKey']) ? $config['apithKey'] : '';
$this->unionId = $config['unionId'];
$this->positionId = $config['positionId'];
$this->pid = $config['unionId'] . '_' . $config['siteId'] . '_' . $config['positionId'];
$this->jdFatory = $jdFatory;
$this->isCurl = isset($config['isCurl']) && ($config['isCurl'] == true) ? true : false;
$this->siteId=$config['siteId'];//缺少赋值
}`
这个调用方式有点奇怪看不懂
vendor/yumufeng/jd-union-sdk/src/Tools/JdGateWay.php Line:211
/**
* 解析参数
* @param $result
* @param bool $raw
* @return mixed
*/
private function parseReps($result, $raw = false)
{
$decodeObject = json_decode($result, true);
if (is_string($decodeObject)) {
return $this->setError($decodeObject);
}
if (is_null($decodeObject)) {
return $this->setError("Api返回结果为空");
}
if ($this->is_auth === true) {
if ($raw == true) {
return $decodeObject;
}
if ($decodeObject['code'] != 1) {
$this->setError($decodeObject['msg']);
return false;
}
return isset($decodeObject['data']) ? $decodeObject['data'] : [];
} else {
$nowLists = current($decodeObject);
if ($nowLists['code'] != 0) {
var_dump($nowLists);die;
return $this->setError(isset($nowLists['msg']) ? $nowLists['msg'] : '错误信息');
}
$finally = json_decode($nowLists['result'], true);
if ($finally['code'] != 200) {
return $this->setError($finally['message']);
}
if ($raw == true) {
return $finally;
}
return isset($finally['data']) ? $finally['data'] : [];
}
}
打印结果:
array(3) {
["code"]=>
string(1) "8"
["zh_desc"]=>
string(161) "时间戳参数与服务器时间差异大于设定值timestamp=2019-07-28 09:22:09(解决方案参考:http://open.jd.com/home/home#/doc/common?listId=533)"
["en_desc"]=>
string(89) "Invalid Timestamp(Solution reference:http://open.jd.com/home/home#/doc/common?listId=533)"
}
此种情况下,key为 zh_desc,不是msg
望楼主更新下,否则调试不太方便:)
src/Api/Apith.php:100
public function createPosition(array $spaceNameList, string $key, $unionType = 1, $type = 4)
{
$param = [
'unionId' => $this->unionId,
'key' => $key,
'unionType' => $unionType,
'type' => $type,
'spaceNameList' => implode(',', $spaceNameList)
];
if ($type == 1) {
$param = array_merge($param, [
'siteId' => $this->siteId
]);
}
return $this->send('createPosition', $param);
}
站点ID,即网站ID/app ID/snsID ,当type传入4以外的值时,siteId为必填
$type == 1 需要改成 $type !== 4
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.