Guide.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | WeChatDeveloper
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2023 ThinkAdmin [ thinkadmin.top ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: https://thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // | 免责声明 ( https://thinkadmin.top/disclaimer )
  11. // +----------------------------------------------------------------------
  12. // | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
  13. // | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
  14. // +----------------------------------------------------------------------
  15. namespace WeMini;
  16. use WeChat\Contracts\BasicWeChat;
  17. /**
  18. * 小程序导购助手
  19. * Class Guide
  20. * @package WeMini
  21. */
  22. class Guide extends BasicWeChat
  23. {
  24. /**
  25. * 服务号添加导购
  26. * @param array $data
  27. * @return array
  28. * @throws \WeChat\Exceptions\InvalidResponseException
  29. * @throws \WeChat\Exceptions\LocalCacheException
  30. */
  31. public function addGuideAcct($data)
  32. {
  33. $url = 'https://api.weixin.qq.com/cgi-bin/guide/addguideacct?access_token=ACCESS_TOKEN';
  34. return $this->callPostApi($url, $data, true);
  35. }
  36. /**
  37. * 服务号删除导购
  38. * @param array $data
  39. * @return array
  40. * @throws \WeChat\Exceptions\InvalidResponseException
  41. * @throws \WeChat\Exceptions\LocalCacheException
  42. */
  43. public function delGuideAcct($data)
  44. {
  45. $url = 'https://api.weixin.qq.com/cgi-bin/guide/delguideacct?access_token=ACCESS_TOKEN';
  46. return $this->callPostApi($url, $data, true);
  47. }
  48. /**
  49. * 服务号获取导购信息
  50. * @param array $data
  51. * @return array
  52. * @throws \WeChat\Exceptions\InvalidResponseException
  53. * @throws \WeChat\Exceptions\LocalCacheException
  54. */
  55. public function getGuideAcct($data)
  56. {
  57. $url = 'https://api.weixin.qq.com/cgi-bin/guide/getguideacct?access_token=ACCESS_TOKEN';
  58. return $this->callPostApi($url, $data, true);
  59. }
  60. /**
  61. * 获取服务号的敏感词信息与自动回复信息
  62. * @return array
  63. * @throws \WeChat\Exceptions\InvalidResponseException
  64. * @throws \WeChat\Exceptions\LocalCacheException
  65. */
  66. public function getGuideAcctConfig()
  67. {
  68. $url = 'https://api.weixin.qq.com/cgi-bin/guide/getguideacctconfig?access_token=ACCESS_TOKEN';
  69. return $this->callPostApi($url, [], true);
  70. }
  71. /**
  72. * 服务号拉取导购列表
  73. * @param integer $page
  74. * @param integer $num
  75. * @return array
  76. * @throws \WeChat\Exceptions\InvalidResponseException
  77. * @throws \WeChat\Exceptions\LocalCacheException
  78. */
  79. public function getGuideAcctList($page = 0, $num = 10)
  80. {
  81. $url = 'https://api.weixin.qq.com/cgi-bin/guide/getguideacctconfig?access_token=ACCESS_TOKEN';
  82. return $this->callPostApi($url, ['page' => $page, 'num' => $num], true);
  83. }
  84. /**
  85. * 获取导购聊天记录
  86. * @param array $data
  87. * @return array
  88. * @throws \WeChat\Exceptions\InvalidResponseException
  89. * @throws \WeChat\Exceptions\LocalCacheException
  90. */
  91. public function getGuideBuyerChatRecord($data)
  92. {
  93. $url = 'https://api.weixin.qq.com/cgi-bin/guide/getguideacct?access_token=ACCESS_TOKEN';
  94. return $this->callPostApi($url, $data, true);
  95. }
  96. /**
  97. * 获取导购快捷回复信息
  98. * @param array $data
  99. * @return array
  100. * @throws \WeChat\Exceptions\InvalidResponseException
  101. * @throws \WeChat\Exceptions\LocalCacheException
  102. */
  103. public function getGuideConfig($data)
  104. {
  105. $url = 'https://api.weixin.qq.com/cgi-bin/guide/getguideconfig?access_token=ACCESS_TOKEN';
  106. return $this->callPostApi($url, $data, true);
  107. }
  108. /**
  109. * 生成导购二维码
  110. * @param array $data
  111. * @return array
  112. * @throws \WeChat\Exceptions\InvalidResponseException
  113. * @throws \WeChat\Exceptions\LocalCacheException
  114. */
  115. public function guideCreateQrCode($data)
  116. {
  117. $url = 'https://api.weixin.qq.com/cgi-bin/guide/guidecreateqrcode?access_token=ACCESS_TOKEN';
  118. return $this->callPostApi($url, $data, true);
  119. }
  120. /**
  121. * @param array $data
  122. * @return array
  123. * @throws \WeChat\Exceptions\InvalidResponseException
  124. * @throws \WeChat\Exceptions\LocalCacheException
  125. */
  126. public function pushShowWxaPathMenu($data)
  127. {
  128. $url = 'https://api.weixin.qq.com/cgi-bin/guide/pushshowwxapathmenu?access_token=ACCESS_TOKEN';
  129. return $this->callPostApi($url, $data, true);
  130. }
  131. /**
  132. * 为服务号设置敏感词与自动回复
  133. * @param array $data
  134. * @return array
  135. * @throws \WeChat\Exceptions\InvalidResponseException
  136. * @throws \WeChat\Exceptions\LocalCacheException
  137. */
  138. public function setGuideAcctConfig($data)
  139. {
  140. $url = 'https://api.weixin.qq.com/cgi-bin/guide/setguideacctconfig?access_token=ACCESS_TOKEN';
  141. return $this->callPostApi($url, $data, true);
  142. }
  143. /**
  144. * 设置导购快捷回复信息
  145. * @param array $data
  146. * @return array
  147. * @throws \WeChat\Exceptions\InvalidResponseException
  148. * @throws \WeChat\Exceptions\LocalCacheException
  149. */
  150. public function setGuideConfig($data)
  151. {
  152. $url = 'https://api.weixin.qq.com/cgi-bin/guide/setguideconfig?access_token=ACCESS_TOKEN';
  153. return $this->callPostApi($url, $data, true);
  154. }
  155. /**
  156. * 更新导购昵称或者头像
  157. * @param array $data
  158. * @return array
  159. * @throws \WeChat\Exceptions\InvalidResponseException
  160. * @throws \WeChat\Exceptions\LocalCacheException
  161. */
  162. public function updateGuideAcct($data)
  163. {
  164. $url = 'https://api.weixin.qq.com/cgi-bin/guide/setguideconfig?access_token=ACCESS_TOKEN';
  165. return $this->callPostApi($url, $data, true);
  166. }
  167. /**
  168. * 添加展示标签信息
  169. * @param array $data
  170. * @return array
  171. * @throws \WeChat\Exceptions\InvalidResponseException
  172. * @throws \WeChat\Exceptions\LocalCacheException
  173. */
  174. public function addGuideBuyerDisplayTag($data)
  175. {
  176. $url = 'https://api.weixin.qq.com/cgi-bin/guide/addguidebuyerdisplaytag?access_token=ACCESS_TOKEN';
  177. return $this->callPostApi($url, $data, true);
  178. }
  179. /**
  180. * 为粉丝添加可查询标签
  181. * @param array $data
  182. * @return array
  183. * @throws \WeChat\Exceptions\InvalidResponseException
  184. * @throws \WeChat\Exceptions\LocalCacheException
  185. */
  186. public function addGuideBuyerTag($data)
  187. {
  188. $url = 'https://api.weixin.qq.com/cgi-bin/guide/addguidebuyertag?access_token=ACCESS_TOKEN';
  189. return $this->callPostApi($url, $data, true);
  190. }
  191. /**
  192. * 添加标签可选值
  193. * @param array $data
  194. * @return array
  195. * @throws \WeChat\Exceptions\InvalidResponseException
  196. * @throws \WeChat\Exceptions\LocalCacheException
  197. */
  198. public function addGuideTagOption($data)
  199. {
  200. $url = 'https://api.weixin.qq.com/cgi-bin/guide/addguidetagoption?access_token=ACCESS_TOKEN';
  201. return $this->callPostApi($url, $data, true);
  202. }
  203. /**
  204. * 删除粉丝标签
  205. * @param array $data
  206. * @return array
  207. * @throws \WeChat\Exceptions\InvalidResponseException
  208. * @throws \WeChat\Exceptions\LocalCacheException
  209. */
  210. public function delGuideBuyerTag($data)
  211. {
  212. $url = 'https://api.weixin.qq.com/cgi-bin/guide/delguidebuyertag?access_token=ACCESS_TOKEN';
  213. return $this->callPostApi($url, $data, true);
  214. }
  215. /**
  216. * 查询展示标签信息
  217. * @param array $data
  218. * @return array
  219. * @throws \WeChat\Exceptions\InvalidResponseException
  220. * @throws \WeChat\Exceptions\LocalCacheException
  221. */
  222. public function getGuideBuyerDisplayTag($data)
  223. {
  224. $url = 'https://api.weixin.qq.com/cgi-bin/guide/getguidebuyerdisplaytag?access_token=ACCESS_TOKEN';
  225. return $this->callPostApi($url, $data, true);
  226. }
  227. /**
  228. * 查询粉丝标签
  229. * @param array $data
  230. * @return array
  231. * @throws \WeChat\Exceptions\InvalidResponseException
  232. * @throws \WeChat\Exceptions\LocalCacheException
  233. */
  234. public function getGuideBuyerTag($data)
  235. {
  236. $url = 'https://api.weixin.qq.com/cgi-bin/guide/getguidebuyertag?access_token=ACCESS_TOKEN';
  237. return $this->callPostApi($url, $data, true);
  238. }
  239. /**
  240. * 查询标签可选值信息
  241. * @return array
  242. * @throws \WeChat\Exceptions\InvalidResponseException
  243. * @throws \WeChat\Exceptions\LocalCacheException
  244. */
  245. public function getGuideTagOption()
  246. {
  247. $url = 'https://api.weixin.qq.com/cgi-bin/guide/getguidetagoption?access_token=ACCESS_TOKEN';
  248. return $this->callPostApi($url, [], true);
  249. }
  250. /**
  251. * 新建可查询标签类型,支持新建4类可查询标签
  252. * @param array $data
  253. * @return array
  254. * @throws \WeChat\Exceptions\InvalidResponseException
  255. * @throws \WeChat\Exceptions\LocalCacheException
  256. */
  257. public function newGuideTagOption($data)
  258. {
  259. $url = 'https://api.weixin.qq.com/cgi-bin/guide/newguidetagoption?access_token=ACCESS_TOKEN';
  260. return $this->callPostApi($url, $data, true);
  261. }
  262. /**
  263. * 根据标签值筛选粉丝
  264. * @param array $data
  265. * @return array
  266. * @throws \WeChat\Exceptions\InvalidResponseException
  267. * @throws \WeChat\Exceptions\LocalCacheException
  268. */
  269. public function queryGuideBuyerByTag($data)
  270. {
  271. $url = 'https://api.weixin.qq.com/cgi-bin/guide/queryguidebuyerbytag?access_token=ACCESS_TOKEN';
  272. $this->registerApi($url, __FUNCTION__, func_get_args());
  273. return $this->callPostApi($url, $data, true);
  274. }
  275. /**
  276. * 为服务号导购添加粉丝
  277. * @param array $data
  278. * @return array
  279. * @throws \WeChat\Exceptions\InvalidResponseException
  280. * @throws \WeChat\Exceptions\LocalCacheException
  281. */
  282. public function addGuideBuyerRelation($data)
  283. {
  284. $url = 'https://api.weixin.qq.com/cgi-bin/guide/addguidebuyerrelation?access_token=ACCESS_TOKEN';
  285. $this->registerApi($url, __FUNCTION__, func_get_args());
  286. return $this->callPostApi($url, $data, true);
  287. }
  288. /**
  289. * 删除导购的粉丝
  290. * @param array $data
  291. * @return array
  292. * @throws \WeChat\Exceptions\InvalidResponseException
  293. * @throws \WeChat\Exceptions\LocalCacheException
  294. */
  295. public function delGuideBuyerRelation($data)
  296. {
  297. $url = 'https://api.weixin.qq.com/cgi-bin/guide/delguidebuyerrelation?access_token=ACCESS_TOKEN';
  298. $this->registerApi($url, __FUNCTION__, func_get_args());
  299. return $this->callPostApi($url, $data, true);
  300. }
  301. /**
  302. * 查询某一个粉丝与导购的绑定关系
  303. * @param array $data
  304. * @return array
  305. * @throws \WeChat\Exceptions\InvalidResponseException
  306. * @throws \WeChat\Exceptions\LocalCacheException
  307. */
  308. public function getGuideBuyerRelation($data)
  309. {
  310. $url = 'https://api.weixin.qq.com/cgi-bin/guide/getguidebuyerrelation?access_token=ACCESS_TOKEN';
  311. $this->registerApi($url, __FUNCTION__, func_get_args());
  312. return $this->callPostApi($url, $data, true);
  313. }
  314. /**
  315. * 通过粉丝信息查询该粉丝与导购的绑定关系
  316. * @param string $openid
  317. * @return array
  318. * @throws \WeChat\Exceptions\InvalidResponseException
  319. * @throws \WeChat\Exceptions\LocalCacheException
  320. */
  321. public function getGuideBuyerRelationByBuyer($openid)
  322. {
  323. $url = 'https://api.weixin.qq.com/cgi-bin/guide/getguidebuyerrelation?access_token=ACCESS_TOKEN';
  324. $this->registerApi($url, __FUNCTION__, func_get_args());
  325. return $this->callPostApi($url, ['openid' => $openid], true);
  326. }
  327. /**
  328. * 拉取导购的粉丝列表
  329. * @param array $data
  330. * @return array
  331. * @throws \WeChat\Exceptions\InvalidResponseException
  332. * @throws \WeChat\Exceptions\LocalCacheException
  333. */
  334. public function getGuideBuyerRelationList($data)
  335. {
  336. $url = 'https://api.weixin.qq.com/cgi-bin/guide/getguidebuyerrelationlist?access_token=ACCESS_TOKEN';
  337. $this->registerApi($url, __FUNCTION__, func_get_args());
  338. return $this->callPostApi($url, $data, true);
  339. }
  340. /**
  341. * 将粉丝从一个导购迁移到另外一个导购下
  342. * @param array $data
  343. * @return array
  344. * @throws \WeChat\Exceptions\InvalidResponseException
  345. * @throws \WeChat\Exceptions\LocalCacheException
  346. */
  347. public function rebindGuideAcctForBuyer($data)
  348. {
  349. $url = 'https://api.weixin.qq.com/cgi-bin/guide/rebindguideacctforbuyer?access_token=ACCESS_TOKEN';
  350. $this->registerApi($url, __FUNCTION__, func_get_args());
  351. return $this->callPostApi($url, $data, true);
  352. }
  353. /**
  354. * 更新粉丝昵称
  355. * @param array $data
  356. * @return array
  357. * @throws \WeChat\Exceptions\InvalidResponseException
  358. * @throws \WeChat\Exceptions\LocalCacheException
  359. */
  360. public function updateGuideBuyerRelation($data)
  361. {
  362. $url = 'https://api.weixin.qq.com/cgi-bin/guide/updateguidebuyerrelation?access_token=ACCESS_TOKEN';
  363. $this->registerApi($url, __FUNCTION__, func_get_args());
  364. return $this->callPostApi($url, $data, true);
  365. }
  366. /**
  367. * 删除小程序卡片素材
  368. * @param array $data
  369. * @return array
  370. * @throws \WeChat\Exceptions\InvalidResponseException
  371. * @throws \WeChat\Exceptions\LocalCacheException
  372. */
  373. public function delGuideCardMaterial($data)
  374. {
  375. $url = 'https://api.weixin.qq.com/cgi-bin/guide/delguidecardmaterial?access_token=ACCESS_TOKEN';
  376. $this->registerApi($url, __FUNCTION__, func_get_args());
  377. return $this->callPostApi($url, $data, true);
  378. }
  379. /**
  380. * 删除图片素材
  381. * @param array $data
  382. * @return array
  383. * @throws \WeChat\Exceptions\InvalidResponseException
  384. * @throws \WeChat\Exceptions\LocalCacheException
  385. */
  386. public function delGuideImageMaterial($data)
  387. {
  388. $url = 'https://api.weixin.qq.com/cgi-bin/guide/delguideimagematerial?access_token=ACCESS_TOKEN';
  389. $this->registerApi($url, __FUNCTION__, func_get_args());
  390. return $this->callPostApi($url, $data, true);
  391. }
  392. /**
  393. * 删除文字素材
  394. * @param array $data
  395. * @return array
  396. * @throws \WeChat\Exceptions\InvalidResponseException
  397. * @throws \WeChat\Exceptions\LocalCacheException
  398. */
  399. public function delGuideWordMaterial($data)
  400. {
  401. $url = 'https://api.weixin.qq.com/cgi-bin/guide/delguidewordmaterial?access_token=ACCESS_TOKEN';
  402. $this->registerApi($url, __FUNCTION__, func_get_args());
  403. return $this->callPostApi($url, $data, true);
  404. }
  405. /**
  406. * 获取小程序卡片素材信息
  407. * @param integer $type
  408. * @return array
  409. * @throws \WeChat\Exceptions\InvalidResponseException
  410. * @throws \WeChat\Exceptions\LocalCacheException
  411. */
  412. public function getGuideCardMaterial($type = 0)
  413. {
  414. $url = 'https://api.weixin.qq.com/cgi-bin/guide/getguidecardmaterial?access_token=ACCESS_TOKEN';
  415. $this->registerApi($url, __FUNCTION__, func_get_args());
  416. return $this->callPostApi($url, ['type' => $type], true);
  417. }
  418. /**
  419. * 获取图片素材信息
  420. * @param integer $type 操作类型
  421. * @param integer $start 分页查询,起始位置
  422. * @param integer $num 分页查询,查询个数
  423. * @return array
  424. * @throws \WeChat\Exceptions\InvalidResponseException
  425. * @throws \WeChat\Exceptions\LocalCacheException
  426. */
  427. public function getGuideImageMaterial($type = 0, $start = 0, $num = 10)
  428. {
  429. $url = 'https://api.weixin.qq.com/cgi-bin/guide/getguideimagematerial?access_token=ACCESS_TOKEN';
  430. $this->registerApi($url, __FUNCTION__, func_get_args());
  431. return $this->callPostApi($url, ['type' => $type, 'start' => $start, 'num' => $num], true);
  432. }
  433. /**
  434. * 获取文字素材信息
  435. * @param integer $type 操作类型
  436. * @param integer $start 分页查询,起始位置
  437. * @param integer $num 分页查询,查询个数
  438. * @return array
  439. * @throws \WeChat\Exceptions\InvalidResponseException
  440. * @throws \WeChat\Exceptions\LocalCacheException
  441. */
  442. public function getGuideWordMaterial($type = 0, $start = 0, $num = 10)
  443. {
  444. $url = 'https://api.weixin.qq.com/cgi-bin/guide/getguidewordmaterial?access_token=ACCESS_TOKEN';
  445. $this->registerApi($url, __FUNCTION__, func_get_args());
  446. return $this->callPostApi($url, ['type' => $type, 'start' => $start, 'num' => $num], true);
  447. }
  448. /**
  449. * 添加小程序卡片素材
  450. * @param array $data
  451. * @return array
  452. * @throws \WeChat\Exceptions\InvalidResponseException
  453. * @throws \WeChat\Exceptions\LocalCacheException
  454. */
  455. public function setGuideCardMaterial($data)
  456. {
  457. $url = 'https://api.weixin.qq.com/cgi-bin/guide/setguidecardmaterial?access_token=ACCESS_TOKEN';
  458. $this->registerApi($url, __FUNCTION__, func_get_args());
  459. return $this->callPostApi($url, $data, true);
  460. }
  461. /**
  462. * 添加图片素材
  463. * @param array $data
  464. * @return array
  465. * @throws \WeChat\Exceptions\InvalidResponseException
  466. * @throws \WeChat\Exceptions\LocalCacheException
  467. */
  468. public function setGuideImageMaterial($data)
  469. {
  470. $url = 'https://api.weixin.qq.com/cgi-bin/guide/setguideimagematerial?access_token=ACCESS_TOKEN';
  471. $this->registerApi($url, __FUNCTION__, func_get_args());
  472. return $this->callPostApi($url, $data, true);
  473. }
  474. /**
  475. * 为服务号添加文字素材
  476. * @param array $data
  477. * @return array
  478. * @throws \WeChat\Exceptions\InvalidResponseException
  479. * @throws \WeChat\Exceptions\LocalCacheException
  480. */
  481. public function setGuideWordMaterial($data)
  482. {
  483. $url = 'https://api.weixin.qq.com/cgi-bin/guide/setguidewordmaterial?access_token=ACCESS_TOKEN';
  484. $this->registerApi($url, __FUNCTION__, func_get_args());
  485. return $this->callPostApi($url, $data, true);
  486. }
  487. }