Wifi.php
11.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
<?php
// +----------------------------------------------------------------------
// | WeChatDeveloper
// +----------------------------------------------------------------------
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://think.ctolog.com
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
// +----------------------------------------------------------------------
namespace WeChat;
use WeChat\Contracts\BasicWeChat;
/**
* 门店 WIFI 管理
* Class Wifi
* @package WeChat
*/
class Wifi extends BasicWeChat
{
/**
* 获取 Wi-Fi 门店列表
* @param integer $pageindex 分页下标,默认从1开始
* @param integer $pagesize 每页的个数,默认10个,最大20个
* @return array
* @throws Exceptions\InvalidResponseException
* @throws Exceptions\LocalCacheException
*/
public function getShopList($pageindex = 1, $pagesize = 2)
{
$url = 'https://api.weixin.qq.com/bizwifi/shop/list?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, ['pageindex' => $pageindex, 'pagesize' => $pagesize]);
}
/**
* 查询门店Wi-Fi信息
* @param integer $shop_id 门店ID
* @return array
* @throws Exceptions\InvalidResponseException
* @throws Exceptions\LocalCacheException
*/
public function getShopWifi($shop_id)
{
$url = 'https://api.weixin.qq.com/bizwifi/shop/list?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, ['shop_id' => $shop_id]);
}
/**
* 修改门店网络信息
* @param integer $shop_id 门店ID
* @param string $old_ssid 旧的无线网络设备的ssid
* @param string $ssid 新的无线网络设备的ssid
* @param string $password 无线网络设备的密码(可选)
* @return array
* @throws Exceptions\InvalidResponseException
* @throws Exceptions\LocalCacheException
*/
public function upShopWifi($shop_id, $old_ssid, $ssid, $password = null)
{
$data = ['shop_id' => $shop_id, 'old_ssid' => $old_ssid, 'ssid' => $ssid];
is_null($password) || $data['password'] = $password;
$url = 'https://api.weixin.qq.com/bizwifi/shop/update?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, $data);
}
/**
* 清空门店网络及设备
* @param integer $shop_id
* @return array
* @throws Exceptions\InvalidResponseException
* @throws Exceptions\LocalCacheException
*/
public function clearShopWifi($shop_id)
{
$url = 'https://api.weixin.qq.com/bizwifi/shop/clean?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, ['shop_id' => $shop_id]);
}
/**
* 添加密码型设备
* @param integer $shop_id 门店ID
* @param string $ssid 无线网络设备的ssid
* @param null|string $password 无线网络设备的密码
* @return array
* @throws Exceptions\InvalidResponseException
* @throws Exceptions\LocalCacheException
*/
public function addShopWifi($shop_id, $ssid, $password = null)
{
$data = ['shop_id' => $shop_id, 'ssid' => $ssid, 'password' => $password];
$url = 'https://api.weixin.qq.com/bizwifi/device/add?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, $data);
}
/**
* 添加portal型设备
* @param integer $shop_id 门店ID
* @param string $ssid 无线网络设备的ssid
* @param bool $reset 重置secretkey,false-不重置,true-重置,默认为false
* @return array
* @throws Exceptions\InvalidResponseException
* @throws Exceptions\LocalCacheException
*/
public function addShopPortal($shop_id, $ssid, $reset = false)
{
$data = ['shop_id' => $shop_id, 'ssid' => $ssid, 'reset' => $reset];
$url = 'https://api.weixin.qq.com/bizwifi/apportal/register?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, $data);
}
/**
* 查询设备
* @param null|integer $shop_id 根据门店id查询
* @param null|integer $pageindex 分页下标,默认从1开始
* @param null|integer $pagesize 每页的个数,默认10个,最大20个
* @return array
* @throws Exceptions\InvalidResponseException
* @throws Exceptions\LocalCacheException
*/
public function queryShopWifi($shop_id = null, $pageindex = null, $pagesize = null)
{
$data = [];
is_null($pagesize) || $data['pagesize'] = $pagesize;
is_null($pageindex) || $data['pageindex'] = $pageindex;
is_null($shop_id) || $data['shop_id'] = $shop_id;
$url = 'https://api.weixin.qq.com/bizwifi/device/list?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, $data);
}
/**
* 删除设备
* @param string $bssid 需要删除的无线网络设备无线mac地址,格式冒号分隔,字符长度17个,并且字母小写,例如:00:1f:7a:ad:5c:a8
* @return array
* @throws Exceptions\InvalidResponseException
* @throws Exceptions\LocalCacheException
*/
public function delShopWifi($bssid)
{
$url = 'https://api.weixin.qq.com/bizwifi/device/delete?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, ['bssid' => $bssid]);
}
/**
* 获取物料二维码
* @param integer $shop_id 门店ID
* @param string $ssid 已添加到门店下的无线网络名称
* @param integer $img_id 物料样式编号:0-纯二维码,可用于自由设计宣传材料;1-二维码物料,155mm×215mm(宽×高),可直接张贴
* @return array
* @throws Exceptions\InvalidResponseException
* @throws Exceptions\LocalCacheException
*/
public function getQrc($shop_id, $ssid, $img_id = 1)
{
$url = 'https://api.weixin.qq.com/bizwifi/qrcode/get?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, ['shop_id' => $shop_id, 'ssid' => $ssid, 'img_id' => $img_id]);
}
/**
* 设置商家主页
* @param integer $shop_id 门店ID
* @param integer $template_id 模板ID,0-默认模板,1-自定义url
* @param null|string $url 自定义链接,当template_id为1时必填
* @return array
* @throws Exceptions\InvalidResponseException
* @throws Exceptions\LocalCacheException
*/
public function setHomePage($shop_id, $template_id, $url = null)
{
$data = ['shop_id' => $shop_id, 'template_id' => $template_id];
is_null($url) && $data['struct'] = ['url' => $url];
$url = 'https://api.weixin.qq.com/bizwifi/homepage/set?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, $data);
}
/**
* 查询商家主页
* @param integer $shop_id 查询的门店id
* @return array
* @throws Exceptions\InvalidResponseException
* @throws Exceptions\LocalCacheException
*/
public function getHomePage($shop_id)
{
$url = 'https://api.weixin.qq.com/bizwifi/homepage/get?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, ['shop_id' => $shop_id]);
}
/**
* 设置微信首页欢迎语
* @param integer $shop_id 门店ID
* @param integer $bar_type 微信首页欢迎语的文本内容:0--欢迎光临+公众号名称;1--欢迎光临+门店名称;2--已连接+公众号名称+WiFi;3--已连接+门店名称+Wi-Fi。
* @return array
* @throws Exceptions\InvalidResponseException
* @throws Exceptions\LocalCacheException
*/
public function setBar($shop_id, $bar_type = 1)
{
$url = 'https://api.weixin.qq.com/bizwifi/bar/set?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, ['shop_id' => $shop_id, 'bar_type' => $bar_type]);
}
/**
* 设置连网完成页
* @param integer $shop_id 门店ID
* @param string $finishpage_url 连网完成页URL
* @return array
* @throws Exceptions\InvalidResponseException
* @throws Exceptions\LocalCacheException
*/
public function setFinishPage($shop_id, $finishpage_url)
{
$url = 'https://api.weixin.qq.com/bizwifi/finishpage/set?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, ['shop_id' => $shop_id, 'finishpage_url' => $finishpage_url]);
}
/**
* Wi-Fi 数据统计
* @param string $begin_date 起始日期时间,格式yyyy-mm-dd,最长时间跨度为30天
* @param string $end_date 结束日期时间戳,格式yyyy-mm-dd,最长时间跨度为30天
* @param integer $shop_id 按门店ID搜索,-1为总统计
* @return array
* @throws Exceptions\InvalidResponseException
* @throws Exceptions\LocalCacheException
*/
public function staticList($begin_date, $end_date, $shop_id = -1)
{
$url = 'https://api.weixin.qq.com/bizwifi/statistics/list?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, ['shop_id' => $shop_id, 'begin_date' => $begin_date, 'end_date' => $end_date]);
}
/**
* 设置门店卡券投放信息
* @param integer $shop_id 门店ID,可设置为0,表示所有门店
* @param integer $card_id 卡券ID
* @param string $card_describe 卡券描述,不能超过18个字符
* @param string $start_time 卡券投放开始时间(单位是秒)
* @param string $end_time 卡券投放结束时间(单位是秒) 注:不能超过卡券的有效期时间
* @return array
* @throws Exceptions\InvalidResponseException
* @throws Exceptions\LocalCacheException
*/
public function setCouponput($shop_id, $card_id, $card_describe, $start_time, $end_time)
{
$data = ['shop_id' => $shop_id, 'card_id' => $card_id, 'card_describe' => $card_describe, 'start_time' => $start_time, 'end_time' => $end_time];
$url = 'https://api.weixin.qq.com/bizwifi/couponput/set?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, $data);
}
/**
* 查询门店卡券投放信息
* @param integer $shop_id 门店ID,可设置为0,表示所有门店
* @return array
* @throws Exceptions\InvalidResponseException
* @throws Exceptions\LocalCacheException
*/
public function getCouponput($shop_id)
{
$url = 'https://api.weixin.qq.com/bizwifi/couponput/get?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, ['shop_id' => $shop_id]);
}
}