|
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
|
|
|
/** |
|
13
|
|
|
* OpenPlatform.php. |
|
14
|
|
|
* |
|
15
|
|
|
* Part of Overtrue\WeChat. |
|
16
|
|
|
* |
|
17
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
18
|
|
|
* file that was distributed with this source code. |
|
19
|
|
|
* |
|
20
|
|
|
* @author mingyoung <[email protected]> |
|
21
|
|
|
* @copyright 2016 |
|
22
|
|
|
* |
|
23
|
|
|
* @see https://github.com/overtrue |
|
24
|
|
|
* @see http://overtrue.me |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
namespace EasyWeChat\OpenPlatform; |
|
28
|
|
|
|
|
29
|
|
|
use EasyWeChat\Support\Traits\PrefixedContainer; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Class OpenPlatform. |
|
33
|
|
|
* |
|
34
|
|
|
* @property \EasyWeChat\OpenPlatform\Api\PreAuthorization $pre_auth |
|
35
|
|
|
* @property \EasyWeChat\OpenPlatform\Guard $server |
|
36
|
|
|
* @property \EasyWeChat\OpenPlatform\AccessToken $access_token |
|
37
|
|
|
* |
|
38
|
|
|
* @method \EasyWeChat\Support\Collection getAuthorizationInfo($authCode = null) |
|
39
|
|
|
* @method \EasyWeChat\Support\Collection getAuthorizationToken($authorizerAppId, $authorizerRefreshToken) |
|
40
|
|
|
* @method \EasyWeChat\Support\Collection getAuthorizerInfo($authorizerAppId) |
|
41
|
|
|
* @method \EasyWeChat\Support\Collection getAuthorizerOption($authorizerAppId, $optionName) |
|
42
|
|
|
* @method \EasyWeChat\Support\Collection setAuthorizerOption($authorizerAppId, $optionName, $optionValue) |
|
43
|
|
|
*/ |
|
44
|
|
|
class OpenPlatform |
|
45
|
|
|
{ |
|
46
|
|
|
use PrefixedContainer; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Create an instance of the EasyWeChat for the given authorizer. |
|
50
|
|
|
* |
|
51
|
|
|
* @param string $appId Authorizer AppId |
|
52
|
|
|
* @param string $refreshToken Authorizer refresh-token |
|
53
|
|
|
* |
|
54
|
|
|
* @return \EasyWeChat\Foundation\Application |
|
55
|
|
|
*/ |
|
56
|
1 |
|
public function createAuthorizer($appId, $refreshToken) |
|
57
|
|
|
{ |
|
58
|
1 |
|
$this->authorization->setAuthorizerAppId($appId); |
|
|
|
|
|
|
59
|
1 |
|
$this->authorization->setAuthorizerRefreshToken($refreshToken); |
|
|
|
|
|
|
60
|
|
|
|
|
61
|
1 |
|
$application = $this->app; |
|
|
|
|
|
|
62
|
1 |
|
$application['access_token'] = $this->authorizer_token; |
|
|
|
|
|
|
63
|
1 |
|
$application['oauth'] = $this->oauth; |
|
|
|
|
|
|
64
|
|
|
|
|
65
|
1 |
|
return $application; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Quick access to the base-api. |
|
70
|
|
|
* |
|
71
|
|
|
* @param string $method |
|
72
|
|
|
* @param array $args |
|
73
|
|
|
* |
|
74
|
|
|
* @return mixed |
|
75
|
|
|
*/ |
|
76
|
|
|
public function __call($method, $args) |
|
77
|
|
|
{ |
|
78
|
|
|
return call_user_func_array([$this->api, $method], $args); |
|
|
|
|
|
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.