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\OpenPlatform\Authorizer\MiniProgram\Setting; |
13
|
|
|
|
14
|
|
|
use EasyWeChat\Kernel\BaseClient; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class Client. |
18
|
|
|
* |
19
|
|
|
* @author ClouderSky <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
class Client extends BaseClient |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* 获取账号可以设置的所有类目. |
25
|
|
|
*/ |
26
|
1 |
|
public function getAllCategories() |
27
|
|
|
{ |
28
|
1 |
|
return $this->httpPostJson('cgi-bin/wxopen/getallcategories'); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* 添加类目. |
33
|
|
|
* |
34
|
|
|
* @param array $categories 类目数组 |
35
|
|
|
*/ |
36
|
1 |
|
public function addCategories(array $categories) |
37
|
|
|
{ |
38
|
1 |
|
$params = ['categories' => $categories]; |
39
|
|
|
|
40
|
1 |
|
return $this->httpPostJson('cgi-bin/wxopen/addcategory', $params); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* 删除类目. |
45
|
|
|
* |
46
|
|
|
* @param int $firstId 一级类目ID |
47
|
|
|
* @param int $secondId 二级类目ID |
48
|
|
|
*/ |
49
|
1 |
|
public function deleteCategories(int $firstId, int $secondId) |
50
|
|
|
{ |
51
|
1 |
|
$params = ['first' => $firstId, 'second' => $secondId]; |
52
|
|
|
|
53
|
1 |
|
return $this->httpPostJson('cgi-bin/wxopen/deletecategory', $params); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* 获取账号已经设置的所有类目. |
58
|
|
|
*/ |
59
|
1 |
|
public function getCategories() |
60
|
|
|
{ |
61
|
1 |
|
return $this->httpPostJson('cgi-bin/wxopen/getcategory'); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* 修改类目. |
66
|
|
|
* |
67
|
|
|
* @param array $category 单个类目 |
68
|
|
|
*/ |
69
|
1 |
|
public function updateCategory(array $category) |
70
|
|
|
{ |
71
|
1 |
|
return $this->httpPostJson('cgi-bin/wxopen/modifycategory', $category); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* 小程序名称设置及改名. |
76
|
|
|
* |
77
|
|
|
* @param string $nickname 昵称 |
78
|
|
|
* @param string $idCardMediaId 身份证照片素材ID |
79
|
|
|
* @param string $licenseMediaId 组织机构代码证或营业执照素材ID |
80
|
|
|
* @param string $otherStuffs 其他证明材料素材ID |
81
|
|
|
*/ |
82
|
1 |
|
public function setNickname( |
83
|
|
|
string $nickname, |
84
|
|
|
string $idCardMediaId = '', |
85
|
|
|
string $licenseMediaId = '', |
86
|
|
|
array $otherStuffs = [] |
87
|
|
|
) { |
88
|
|
|
$params = [ |
89
|
1 |
|
'nick_name' => $nickname, |
90
|
1 |
|
'id_card' => $idCardMediaId, |
91
|
1 |
|
'license' => $licenseMediaId, |
92
|
|
|
]; |
93
|
|
|
|
94
|
1 |
|
for ($i = \count($otherStuffs) - 1; $i >= 0; --$i) { |
95
|
1 |
|
$params['naming_other_stuff_'.($i + 1)] = $otherStuffs[$i]; |
96
|
|
|
} |
97
|
|
|
|
98
|
1 |
|
return $this->httpPostJson('wxa/setnickname', $params); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* 小程序改名审核状态查询. |
103
|
|
|
* |
104
|
|
|
* @param int $auditId 审核单id |
105
|
|
|
*/ |
106
|
1 |
|
public function getNicknameAuditStatus($auditId) |
107
|
|
|
{ |
108
|
1 |
|
$params = ['audit_id' => $auditId]; |
109
|
|
|
|
110
|
1 |
|
return $this->httpPostJson('wxa/api_wxa_querynickname', $params); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* 微信认证名称检测. |
115
|
|
|
* |
116
|
|
|
* @param string $nickname 名称(昵称) |
117
|
|
|
*/ |
118
|
1 |
|
public function isAvailableNickname($nickname) |
119
|
|
|
{ |
120
|
1 |
|
$params = ['nick_name' => $nickname]; |
121
|
|
|
|
122
|
1 |
|
return $this->httpPostJson( |
123
|
1 |
|
'cgi-bin/wxverify/checkwxverifynickname', $params); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* 查询小程序当前隐私设置(是否可被搜索). |
128
|
|
|
* |
129
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
130
|
|
|
*/ |
131
|
|
|
public function getSearchStatus() |
132
|
|
|
{ |
133
|
|
|
return $this->httpGet('wxa/getwxasearchstatus'); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* 设置小程序可被搜素. |
138
|
|
|
* |
139
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
140
|
|
|
*/ |
141
|
|
|
public function setSearchable() |
142
|
|
|
{ |
143
|
|
|
return $this->httpPostJson('wxa/changewxasearchstatus', [ |
144
|
|
|
'status' => 0, |
145
|
|
|
]); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* 设置小程序不可被搜素. |
150
|
|
|
* |
151
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
152
|
|
|
*/ |
153
|
|
|
public function setUnsearchable() |
154
|
|
|
{ |
155
|
|
|
return $this->httpPostJson('wxa/changewxasearchstatus', [ |
156
|
|
|
'status' => 1, |
157
|
|
|
]); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* 获取展示的公众号信息. |
162
|
|
|
* |
163
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
164
|
|
|
*/ |
165
|
|
|
public function getDisplayedOfficialAccount() |
166
|
|
|
{ |
167
|
|
|
return $this->httpGet('wxa/getshowwxaitem'); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* 设置展示的公众号. |
172
|
|
|
* |
173
|
|
|
* @param string|bool $appid |
174
|
|
|
* |
175
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
176
|
|
|
*/ |
177
|
|
|
public function setDisplayedOfficialAccount($appid) |
178
|
|
|
{ |
179
|
|
|
return $this->httpPostJson('wxa/updateshowwxaitem', [ |
180
|
|
|
'appid' => $appid ?: null, |
181
|
|
|
'wxa_subscribe_biz_flag' => $appid ? 1 : 0, |
182
|
|
|
]); |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* 获取可以用来设置的公众号列表. |
187
|
|
|
* |
188
|
|
|
* @param int $page |
189
|
|
|
* @param int $num |
190
|
|
|
* |
191
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
192
|
|
|
*/ |
193
|
|
|
public function getDisplayableOfficialAccounts(int $page, int $num) |
194
|
|
|
{ |
195
|
|
|
return $this->httpGet('wxa/getwxamplinkforshow', [ |
196
|
|
|
'page' => $page, |
197
|
|
|
'num' => $num, |
198
|
|
|
]); |
199
|
|
|
} |
200
|
|
|
} |
201
|
|
|
|