|
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\OfficialAccount\Base; |
|
13
|
|
|
|
|
14
|
|
|
use EasyWeChat\Kernel\BaseClient; |
|
15
|
|
|
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Class Client. |
|
19
|
|
|
* |
|
20
|
|
|
* @author mingyoung <[email protected]> |
|
21
|
|
|
*/ |
|
22
|
|
|
class Client extends BaseClient |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* Clear quota. |
|
26
|
|
|
* |
|
27
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
|
28
|
|
|
* |
|
29
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
30
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
|
31
|
|
|
*/ |
|
32
|
1 |
|
public function clearQuota() |
|
33
|
|
|
{ |
|
34
|
|
|
$params = [ |
|
35
|
1 |
|
'appid' => $this->app['config']['app_id'], |
|
36
|
|
|
]; |
|
37
|
|
|
|
|
38
|
1 |
|
return $this->httpPostJson('cgi-bin/clear_quota', $params); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Get wechat callback ip. |
|
43
|
|
|
* |
|
44
|
|
|
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string |
|
45
|
|
|
* |
|
46
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
47
|
|
|
*/ |
|
48
|
1 |
|
public function getValidIps() |
|
49
|
|
|
{ |
|
50
|
1 |
|
return $this->httpGet('cgi-bin/getcallbackip'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Check the callback address network. |
|
55
|
|
|
* |
|
56
|
|
|
* @param string $action |
|
57
|
|
|
* @param string $operator |
|
58
|
|
|
* |
|
59
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
|
60
|
|
|
* |
|
61
|
|
|
* @throws InvalidArgumentException |
|
62
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
|
63
|
|
|
* |
|
64
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
|
65
|
|
|
*/ |
|
66
|
1 |
|
public function checkCallbackUrl(string $action = 'all', string $operator = 'DEFAULT') |
|
67
|
|
|
{ |
|
68
|
1 |
|
if (!in_array($action, ['dns', 'ping', 'all'])) { |
|
69
|
1 |
|
throw new InvalidArgumentException('The action must be dns, ping, all.'); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
1 |
|
$operator = strtoupper($operator); |
|
73
|
|
|
|
|
74
|
1 |
|
if (!in_array($operator, ['CHINANET', 'UNICOM', 'CAP', 'DEFAULT'])) { |
|
75
|
1 |
|
throw new InvalidArgumentException('The operator must be CHINANET, UNICOM, CAP, DEFAULT.'); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
$params = [ |
|
79
|
1 |
|
'action' => $action, |
|
80
|
1 |
|
'check_operator' => $operator, |
|
81
|
|
|
]; |
|
82
|
|
|
|
|
83
|
1 |
|
return $this->httpPostJson('cgi-bin/callback/check', $params); |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|