OaGlobalsoApi.php
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
namespace App\Helper;
use App\Utils\HttpUtils;
use GuzzleHttp\Exception\GuzzleException;
/**
* Class OaGlobalsoApi
* @package App\Helper
* @author zbj
* @date 2023/6/27
*/
class OaGlobalsoApi
{
//接口地址
protected $url = 'https://oa.cmer.com';
protected $token = '';
public function __construct()
{
$this->token = md5('oa' . date('Y-m-d'));
}
/**
* 项目信息
* @author zbj
* @date 2023/5/17
*/
public function order_info($order_id)
{
$api_url = $this->url . '/api/order_info?token='.$this->token.'&order_id='.$order_id;
// $res = http_get($api_url,["charset" => "UTF-8"]);
$client = new \GuzzleHttp\Client();
$data = $client->request('GET', $api_url, [
'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号
])->getBody()->getContents();
$res = json_decode($data, true);
return $res;
}
/**
* 渠道信息
* @author zbj
* @date 2023/5/17
*/
public function agents_lists()
{
$api_url = $this->url . '/api/agents_lists';
$params = [
'token' => $this->token,
];
try {
// $res = HttpUtils::get($api_url, $params);
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', $api_url .'?'. http_build_query($params), [
'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号
])->getBody()->getContents();
$res = Arr::s2a($res);
} catch (\Exception | GuzzleException $e) {
errorLog('渠道信息', $params, $e);
return false;
}
return $res;
}
}