Total Complexity | 7 |
Total Lines | 52 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
4 | trait GatewayTrait |
||
5 | { |
||
6 | /** |
||
7 | * @var 缓存处理 |
||
|
|||
8 | */ |
||
9 | protected $cache; |
||
10 | |||
11 | /** |
||
12 | * Description: 执行GET请求操作 |
||
13 | * @author: JiaMeng <[email protected]> |
||
14 | * Updater: |
||
15 | * @param $url |
||
16 | * @param array $params |
||
17 | * @param array $headers |
||
18 | * @return string |
||
19 | */ |
||
20 | protected function get($url, $params = [], $headers = []) |
||
21 | { |
||
22 | return \tinymeng\tools\HttpRequest::httpGet($url, $params,$headers); |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * Description: 执行POST请求操作 |
||
27 | * @author: JiaMeng <[email protected]> |
||
28 | * Updater: |
||
29 | * @param $url |
||
30 | * @param array $params |
||
31 | * @param array $headers |
||
32 | * @return mixed |
||
33 | */ |
||
34 | protected function post($url, $params = [], $headers = []) |
||
35 | { |
||
36 | $headers[] = 'Accept: application/json';//GitHub需要的header |
||
37 | return \tinymeng\tools\HttpRequest::httpPost($url, $params,$headers); |
||
38 | } |
||
39 | |||
40 | |||
41 | public function setCache($cache) |
||
42 | { |
||
43 | $this->cache = $cache; |
||
44 | return $this; |
||
45 | } |
||
46 | |||
47 | protected function getTokenFromCache($key) |
||
50 | } |
||
51 | |||
52 | protected function setTokenToCache($key, $token, $expires = 7200) |
||
53 | { |
||
59 | } |