1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace YEntWeChat\User; |
4
|
|
|
|
5
|
|
|
use YEntWeChat\Core\AbstractAPI; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class Tag. |
9
|
|
|
*/ |
10
|
|
|
class Tag extends AbstractAPI |
11
|
|
|
{ |
12
|
|
|
const API_GET = 'https://qyapi.weixin.qq.com/cgi-bin/tag/list'; |
13
|
|
|
const API_CREATE = 'https://qyapi.weixin.qq.com/cgi-bin/tag/create'; |
14
|
|
|
const API_UPDATE = 'https://qyapi.weixin.qq.com/cgi-bin/tag/update'; |
15
|
|
|
const API_DELETE = 'https://qyapi.weixin.qq.com/cgi-bin/tag/delete'; |
16
|
|
|
const API_MEMBER_BATCH_TAG = 'https://qyapi.weixin.qq.com/cgi-bin/tag/addtagusers'; |
17
|
|
|
const API_MEMBER_BATCH_UNTAG = 'https://qyapi.weixin.qq.com/cgi-bin/tag/deltagusers'; |
18
|
|
|
const API_USERS_OF_TAG = 'https://qyapi.weixin.qq.com/cgi-bin/tag/get'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Create tag. |
22
|
|
|
* |
23
|
|
|
* @param string $name |
24
|
|
|
* @param null $tagI |
|
|
|
|
25
|
|
|
* |
26
|
|
|
* @return int |
27
|
|
|
*/ |
28
|
|
View Code Duplication |
public function create($name, $tagId = null) |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
$params = [ |
31
|
|
|
'tagname' => $name, |
32
|
|
|
'tagid' => $tagId, |
33
|
|
|
]; |
34
|
|
|
|
35
|
|
|
return $this->parseJSON('json', [self::API_CREATE, $params]); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* List all tags. |
40
|
|
|
* |
41
|
|
|
* @return array |
42
|
|
|
*/ |
43
|
|
|
public function lists() |
44
|
|
|
{ |
45
|
|
|
return $this->parseJSON('get', [self::API_GET]); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Update a tag name. |
50
|
|
|
* |
51
|
|
|
* @param int $tagId |
52
|
|
|
* @param string $name |
53
|
|
|
* |
54
|
|
|
* @return bool |
55
|
|
|
*/ |
56
|
|
View Code Duplication |
public function update($tagId, $name) |
|
|
|
|
57
|
|
|
{ |
58
|
|
|
$params = [ |
59
|
|
|
'tagid' => $tagId, |
60
|
|
|
'tagname' => $name, |
61
|
|
|
]; |
62
|
|
|
|
63
|
|
|
return $this->parseJSON('json', [self::API_UPDATE, $params]); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Delete tag. |
68
|
|
|
* |
69
|
|
|
* @param int $tagId |
70
|
|
|
* |
71
|
|
|
* @return bool |
72
|
|
|
*/ |
73
|
|
View Code Duplication |
public function delete($tagId) |
|
|
|
|
74
|
|
|
{ |
75
|
|
|
$params = [ |
76
|
|
|
'tagid' => $tagId, |
77
|
|
|
]; |
78
|
|
|
|
79
|
|
|
return $this->parseJSON('json', [self::API_DELETE, $params]); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Get users from a tag. |
84
|
|
|
* |
85
|
|
|
* @param string $tagId |
86
|
|
|
* |
87
|
|
|
* @return int |
88
|
|
|
*/ |
89
|
|
|
public function usersOfTag($tagId) |
90
|
|
|
{ |
91
|
|
|
$params = ['tagid' => $tagId]; |
92
|
|
|
|
93
|
|
|
return $this->parseJSON('json', [self::API_USERS_OF_TAG, $params]); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Batch tag users. |
98
|
|
|
* |
99
|
|
|
* @param $tagId |
100
|
|
|
* @param array $userIds |
101
|
|
|
* @param array $partyIds |
102
|
|
|
* |
103
|
|
|
* @return bool |
104
|
|
|
*/ |
105
|
|
View Code Duplication |
public function batchTagUsers($tagId, array $userIds = [], array $partyIds = []) |
|
|
|
|
106
|
|
|
{ |
107
|
|
|
$params = [ |
108
|
|
|
'tagid' => $tagId, |
109
|
|
|
'userlist' => $userIds, |
110
|
|
|
'partylist' => $partyIds, |
111
|
|
|
]; |
112
|
|
|
|
113
|
|
|
return $this->parseJSON('json', [self::API_MEMBER_BATCH_TAG, $params]); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Untag users from a tag. |
118
|
|
|
* |
119
|
|
|
* @param $tagId |
120
|
|
|
* @param array $userIds |
121
|
|
|
* @param array $partyIds |
122
|
|
|
* |
123
|
|
|
* @return bool |
124
|
|
|
*/ |
125
|
|
View Code Duplication |
public function batchUntagUsers($tagId, array $userIds = [], array $partyIds = []) |
|
|
|
|
126
|
|
|
{ |
127
|
|
|
$params = [ |
128
|
|
|
'tagid' => $tagId, |
129
|
|
|
'userlist' => $userIds, |
130
|
|
|
'partylist' => $partyIds, |
131
|
|
|
]; |
132
|
|
|
|
133
|
|
|
return $this->parseJSON('json', [self::API_MEMBER_BATCH_UNTAG, $params]); |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.