Guide.php 19 KB

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