1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EasyIM\TencentIM\Sns; |
4
|
|
|
|
5
|
|
|
use EasyIM\Kernel\BaseClient; |
6
|
|
|
use EasyIM\TencentIM\Kernel\Constant\SnsConstant; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class BlackListClient |
10
|
|
|
* |
11
|
|
|
* @package EasyIM\TencentIM\Sns |
12
|
|
|
* @author longing <[email protected]> |
13
|
|
|
*/ |
14
|
|
|
class BlackListClient extends BaseClient |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* Add blacklist. |
18
|
|
|
* |
19
|
|
|
* @param string $fromAccount |
20
|
|
|
* @param array $toAccount |
21
|
|
|
* |
22
|
|
|
* @return array|\EasyIM\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
23
|
|
|
* @throws \EasyIM\Kernel\Exceptions\InvalidConfigException |
24
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
25
|
|
|
*/ |
26
|
|
|
public function add(string $fromAccount, array $toAccount) |
27
|
|
|
{ |
28
|
|
|
$params = [ |
29
|
|
|
'From_Account' => $fromAccount, |
30
|
|
|
'To_Account' => $toAccount |
31
|
|
|
]; |
32
|
|
|
|
33
|
|
|
return $this->httpPostJson('sns/black_list_add', $params); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Delete blacklist. |
38
|
|
|
* |
39
|
|
|
* @param string $fromAccount |
40
|
|
|
* @param array $toAccount |
41
|
|
|
* |
42
|
|
|
* @return array|\EasyIM\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
43
|
|
|
* @throws \EasyIM\Kernel\Exceptions\InvalidConfigException |
44
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
45
|
|
|
*/ |
46
|
|
|
public function del(string $fromAccount, array $toAccount) |
47
|
|
|
{ |
48
|
|
|
$params = [ |
49
|
|
|
'From_Account' => $fromAccount, |
50
|
|
|
'To_Account' => $toAccount |
51
|
|
|
]; |
52
|
|
|
|
53
|
|
|
return $this->httpPostJson('sns/black_list_delete', $params); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Get blacklist. |
59
|
|
|
* |
60
|
|
|
* @param string $fromAccount |
61
|
|
|
* @param int $startIndex |
62
|
|
|
* @param int $maxLimited |
63
|
|
|
* @param int $lastSequence |
64
|
|
|
* |
65
|
|
|
* @return array|\EasyIM\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
66
|
|
|
* @throws \EasyIM\Kernel\Exceptions\InvalidConfigException |
67
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
68
|
|
|
*/ |
69
|
|
|
public function pull(string $fromAccount, int $startIndex = 0, int $maxLimited = 20, int $lastSequence = 0) |
70
|
|
|
{ |
71
|
|
|
$params = [ |
72
|
|
|
'From_Account' => $fromAccount, |
73
|
|
|
'StartIndex' => $startIndex, |
74
|
|
|
'MaxLimited' => $maxLimited, |
75
|
|
|
'LastSequence' => $lastSequence |
76
|
|
|
]; |
77
|
|
|
|
78
|
|
|
return $this->httpPostJson('sns/black_list_get', $params); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Check blacklist. |
84
|
|
|
* |
85
|
|
|
* @param string $fromAccount |
86
|
|
|
* @param array $toAccount |
87
|
|
|
* @param string $checkType type detail https://cloud.tencent.com/document/product/269/1501#.E6.A0.A1.E9.AA.8C.E9.BB.91.E5.90.8D.E5.8D.95 |
88
|
|
|
* |
89
|
|
|
* @return array|\EasyIM\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
90
|
|
|
* @throws \EasyIM\Kernel\Exceptions\InvalidConfigException |
91
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
92
|
|
|
*/ |
93
|
|
|
public function check(string $fromAccount, array $toAccount, string $checkType = SnsConstant::BLACK_CHECK_RESULT_TYPE_BOTH) |
94
|
|
|
{ |
95
|
|
|
$params = [ |
96
|
|
|
'From_Account' => $fromAccount, |
97
|
|
|
'To_Account' => $toAccount, |
98
|
|
|
'CheckType' => $checkType |
99
|
|
|
]; |
100
|
|
|
|
101
|
|
|
return $this->httpPostJson('sns/black_list_check', $params); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|