Skip to content

Commit 25ce72a

Browse files
committed
- 测试淘宝官方SDK
1 parent 95b370a commit 25ce72a

File tree

104 files changed

+10162
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+10162
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
## v6.0.122 / 2020-11-28
1+
## v6.0.123 / 2020-11-19
2+
- 测试淘宝官方SDK
3+
4+
## v6.0.122 / 2020-11-18
25
- 增加订单侠开放平台接口
36

47
## v6.0.121 / 2020-11-12

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"qcloud/cos-sdk-v5": "^2.0",
4141
"qiniu/php-sdk": "^7.2",
4242
"upyun/sdk": "^3.4",
43-
"phpoffice/phpspreadsheet": "^1.14"
43+
"phpoffice/phpspreadsheet": "1.12.0"
4444
},
4545
"require-dev": {
4646
"symfony/var-dumper": "^4.2"

src/common.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
/**
2626
* 定义当前版本
2727
*/
28-
const VERSION = '6.0.122';
28+
const VERSION = '6.0.123';
2929

3030
if (!function_exists('get_ip_info')) {
3131
/**

src/service/taobao/TaoBaoService.php

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?php
2+
3+
namespace DtApp\ThinkLibrary\service\taobao;
4+
5+
use DtApp\ThinkLibrary\Service;
6+
use TbkScInvitecodeGetRequest;
7+
use TopClient;
8+
9+
/**
10+
* 淘宝服务
11+
* Class TaoBaoService
12+
* @package DtApp\ThinkLibrary\service\taobao
13+
*/
14+
class TaoBaoService extends Service
15+
{
16+
/**
17+
* TOP分配给应用的
18+
* @var string
19+
*/
20+
private $app_key, $app_secret = "";
21+
22+
/**
23+
* 需要发送的的参数
24+
* @var
25+
*/
26+
private $param;
27+
28+
/**
29+
* 响应内容
30+
* @var
31+
*/
32+
private $output;
33+
34+
/**
35+
* 配置应用的AppKey
36+
* @param string $appKey
37+
* @return $this
38+
*/
39+
public function appKey(string $appKey): self
40+
{
41+
$this->app_key = $appKey;
42+
return $this;
43+
}
44+
45+
/**
46+
* 应用AppSecret
47+
* @param string $appSecret
48+
* @return $this
49+
*/
50+
public function appSecret(string $appSecret): self
51+
{
52+
$this->app_secret = $appSecret;
53+
return $this;
54+
}
55+
56+
/**
57+
* 请求参数
58+
* @param array $param
59+
* @return $this
60+
*/
61+
public function param(array $param): self
62+
{
63+
$this->param = $param;
64+
return $this;
65+
}
66+
67+
public function scInvitecodeGet($sessionKey): self
68+
{
69+
$c = new TopClient();
70+
$c->appkey = $this->app_key;
71+
$c->secretKey = $this->app_secret;
72+
$req = new TbkScInvitecodeGetRequest();
73+
if (isset($this->param['relation_id'])) {
74+
$req->setRelationId($this->param['relation_id']);
75+
}
76+
if (isset($this->param['relation_app'])) {
77+
$req->setRelationApp($this->param['relation_app']);
78+
}
79+
if (isset($this->param['code_type'])) {
80+
$req->setCodeType($this->param['code_type']);
81+
}
82+
$resp = $c->execute($req, $sessionKey);
83+
return $this;
84+
}
85+
86+
/**
87+
* 返回Array
88+
* @return array|mixed
89+
*/
90+
public function toArray()
91+
{
92+
if (isset($this->output['error_response'])) {
93+
// 错误
94+
if (is_array($this->output)) {
95+
return $this->output;
96+
}
97+
if (is_object($this->output)) {
98+
$this->output = json_encode($this->output, JSON_UNESCAPED_UNICODE);
99+
}
100+
return json_decode($this->output, true);
101+
}
102+
103+
// 正常
104+
if (is_array($this->output)) {
105+
return $this->output;
106+
}
107+
if (is_object($this->output)) {
108+
$this->output = json_encode($this->output, JSON_UNESCAPED_UNICODE);
109+
}
110+
$this->output = json_decode($this->output, true);
111+
return $this->output;
112+
}
113+
}

src/service/taobao/bin/Autoloader.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
class Autoloader{
4+
5+
/**
6+
* 类库自动加载,写死路径,确保不加载其他文件。
7+
* @param string $class 对象类名
8+
* @return void
9+
*/
10+
public static function autoload($class) {
11+
$name = $class;
12+
if(false !== strpos($name,'\\')){
13+
$name = strstr($class, '\\', true);
14+
}
15+
16+
$filename = TOP_AUTOLOADER_PATH."/top/".$name.".php";
17+
if(is_file($filename)) {
18+
include $filename;
19+
return;
20+
}
21+
22+
$filename = TOP_AUTOLOADER_PATH."/top/request/".$name.".php";
23+
if(is_file($filename)) {
24+
include $filename;
25+
return;
26+
}
27+
28+
$filename = TOP_AUTOLOADER_PATH."/top/domain/".$name.".php";
29+
if(is_file($filename)) {
30+
include $filename;
31+
return;
32+
}
33+
34+
$filename = TOP_AUTOLOADER_PATH."/aliyun/".$name.".php";
35+
if(is_file($filename)) {
36+
include $filename;
37+
return;
38+
}
39+
40+
$filename = TOP_AUTOLOADER_PATH."/aliyun/request/".$name.".php";
41+
if(is_file($filename)) {
42+
include $filename;
43+
return;
44+
}
45+
46+
$filename = TOP_AUTOLOADER_PATH."/aliyun/domain/".$name.".php";
47+
if(is_file($filename)) {
48+
include $filename;
49+
return;
50+
}
51+
52+
$filename = TOP_AUTOLOADER_PATH."/dingtalk/".$name.".php";
53+
if(is_file($filename)) {
54+
include $filename;
55+
return;
56+
}
57+
$filename = TOP_AUTOLOADER_PATH."/dingtalk/request/".$name.".php";
58+
if(is_file($filename)) {
59+
include $filename;
60+
return;
61+
}
62+
63+
$filename = TOP_AUTOLOADER_PATH."/dingtalk/domain/".$name.".php";
64+
if(is_file($filename)) {
65+
include $filename;
66+
return;
67+
}
68+
69+
$filename = TOP_AUTOLOADER_PATH."/QimenCloud/".$name.".php";
70+
if(is_file($filename)) {
71+
include $filename;
72+
return;
73+
}
74+
}
75+
}
76+
77+
spl_autoload_register('Autoloader::autoload');
78+
?>

src/service/taobao/bin/OapiTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
include "TopSdk.php";
3+
date_default_timezone_set('Asia/Shanghai');
4+
5+
$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_POST , DingTalkConstant::$FORMAT_JSON);
6+
$req = new OapiMediaUploadRequest;
7+
$req->setType("image");
8+
$req->setMedia(array('type'=>'application/octet-stream','filename'=>'image.png', 'content' => file_get_contents('/Users/test/image.png')));
9+
$resp=$c->execute($req, "******","https://oapi.dingtalk.com/media/upload");
10+
var_dump($resp)
11+
12+
?>

0 commit comments

Comments
 (0)