1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the overtrue/wechat. |
5
|
|
|
* |
6
|
|
|
* (c) overtrue <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the MIT license that is bundled |
9
|
|
|
* with this source code in the file LICENSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace EasyWeChat\OpenWork\Work\Auth; |
13
|
|
|
|
14
|
|
|
use EasyWeChat\Kernel\AccessToken as BaseAccessToken; |
15
|
|
|
use EasyWeChat\OpenWork\Application; |
16
|
|
|
use Pimple\Container; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* AccessToken. |
20
|
|
|
* |
21
|
|
|
* @author xiaomin <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
class AccessToken extends BaseAccessToken |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
protected $requestMethod = 'POST'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var string 授权方企业ID |
32
|
|
|
*/ |
33
|
|
|
protected $authCorpid; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string 授权方企业永久授权码,通过get_permanent_code获取 |
37
|
|
|
*/ |
38
|
|
|
protected $permanentCode; |
39
|
|
|
|
40
|
|
|
protected $component; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* AccessToken constructor. |
44
|
|
|
* |
45
|
|
|
* @param Container $app |
46
|
|
|
* @param string $authCorpId |
47
|
|
|
* @param string $permanentCode |
48
|
|
|
* @param Application $component |
49
|
|
|
*/ |
50
|
3 |
|
public function __construct(Container $app, String $authCorpId, String $permanentCode, Application $component) |
51
|
|
|
{ |
52
|
3 |
|
$this->authCorpid = $authCorpId; |
|
|
|
|
53
|
3 |
|
$this->permanentCode = $permanentCode; |
54
|
3 |
|
$this->component = $component; |
|
|
|
|
55
|
3 |
|
parent::__construct($app); |
56
|
3 |
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Credential for get token. |
60
|
|
|
* |
61
|
|
|
* @return array |
62
|
|
|
*/ |
63
|
1 |
|
protected function getCredentials(): array |
64
|
|
|
{ |
65
|
|
|
return [ |
66
|
1 |
|
'auth_corpid' => $this->authCorpid, |
67
|
1 |
|
'permanent_code' => $this->permanentCode, |
68
|
|
|
]; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return string |
73
|
|
|
*/ |
74
|
1 |
|
public function getEndpoint(): string |
75
|
|
|
{ |
76
|
1 |
|
return 'cgi-bin/service/get_corp_token?'.http_build_query([ |
77
|
1 |
|
'suite_access_token' => $this->component['suite_access_token']->getToken()['suite_access_token'], |
78
|
|
|
]); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.