Client.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. <?php
  2. /*
  3. * This file is part of the overtrue/wechat.
  4. *
  5. * (c) overtrue <i@overtrue.me>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace addons\shopro\library\mplive;
  11. use EasyWeChat\Kernel\BaseClient;
  12. /**
  13. * Class Client.
  14. *
  15. * @author Abbotton <uctoo@foxmail.com>
  16. */
  17. class Client extends BaseClient
  18. {
  19. /**
  20. * Add broadcast goods.
  21. *
  22. * @param array $goodsInfo
  23. *
  24. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  25. *
  26. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  27. * @throws \GuzzleHttp\Exception\GuzzleException
  28. */
  29. public function create(array $goodsInfo)
  30. {
  31. $params = [
  32. 'goodsInfo' => $goodsInfo,
  33. ];
  34. return $this->httpPostJson('wxaapi/broadcast/goods/add', $params);
  35. }
  36. /**
  37. * Reset audit.
  38. *
  39. * @param int $auditId
  40. * @param int $goodsId
  41. *
  42. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  43. *
  44. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  45. * @throws \GuzzleHttp\Exception\GuzzleException
  46. */
  47. public function resetAudit(int $auditId, int $goodsId)
  48. {
  49. $params = [
  50. 'auditId' => $auditId,
  51. 'goodsId' => $goodsId,
  52. ];
  53. return $this->httpPostJson('wxaapi/broadcast/goods/resetaudit', $params);
  54. }
  55. /**
  56. * Resubmit audit goods.
  57. *
  58. * @param int $goodsId
  59. *
  60. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  61. *
  62. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  63. * @throws \GuzzleHttp\Exception\GuzzleException
  64. */
  65. public function resubmitAudit(int $goodsId)
  66. {
  67. $params = [
  68. 'goodsId' => $goodsId,
  69. ];
  70. return $this->httpPostJson('wxaapi/broadcast/goods/audit', $params);
  71. }
  72. /**
  73. * Delete broadcast goods.
  74. *
  75. * @param int $goodsId
  76. *
  77. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  78. *
  79. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  80. * @throws \GuzzleHttp\Exception\GuzzleException
  81. */
  82. public function delete(int $goodsId)
  83. {
  84. $params = [
  85. 'goodsId' => $goodsId,
  86. ];
  87. return $this->httpPostJson('wxaapi/broadcast/goods/delete', $params);
  88. }
  89. /**
  90. * Update goods info.
  91. *
  92. * @param array $goodsInfo
  93. *
  94. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  95. *
  96. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  97. * @throws \GuzzleHttp\Exception\GuzzleException
  98. */
  99. public function update(array $goodsInfo)
  100. {
  101. $params = [
  102. 'goodsInfo' => $goodsInfo,
  103. ];
  104. return $this->httpPostJson('wxaapi/broadcast/goods/update', $params);
  105. }
  106. /**
  107. * Get goods information and review status.
  108. *
  109. * @param array $goodsIdArray
  110. *
  111. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  112. *
  113. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  114. * @throws \GuzzleHttp\Exception\GuzzleException
  115. */
  116. public function getGoodsWarehouse(array $goodsIdArray)
  117. {
  118. $params = [
  119. 'goods_ids' => $goodsIdArray,
  120. ];
  121. return $this->httpPostJson('wxa/business/getgoodswarehouse', $params);
  122. }
  123. /**
  124. * Get goods list based on status
  125. *
  126. * @param array $params
  127. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  128. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  129. * @throws \GuzzleHttp\Exception\GuzzleException
  130. */
  131. public function getApproved(array $params)
  132. {
  133. return $this->httpGet('wxaapi/broadcast/goods/getapproved', $params);
  134. }
  135. /**
  136. * Add goods to the designated live room.
  137. *
  138. * @param array $params
  139. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  140. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  141. * @throws \GuzzleHttp\Exception\GuzzleException
  142. */
  143. public function addGoods(array $params)
  144. {
  145. return $this->httpPost('wxaapi/broadcast/room/addgoods', $params);
  146. }
  147. /**
  148. * Get Room List.
  149. *
  150. * @param int $start
  151. * @param int $limit
  152. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  153. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  154. * @throws \GuzzleHttp\Exception\GuzzleException
  155. * @author onekb <1@1kb.ren>
  156. */
  157. public function getRooms(int $start = 0, int $limit = 10)
  158. {
  159. $params = [
  160. 'start' => $start,
  161. 'limit' => $limit,
  162. ];
  163. return $this->httpPostJson('wxa/business/getliveinfo', $params);
  164. }
  165. /**
  166. * Get Playback List.
  167. *
  168. * @param int $roomId
  169. * @param int $start
  170. * @param int $limit
  171. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  172. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  173. * @throws \GuzzleHttp\Exception\GuzzleException
  174. * @author onekb <1@1kb.ren>
  175. */
  176. public function getPlaybacks(int $roomId, int $start = 0, int $limit = 10)
  177. {
  178. $params = [
  179. 'action' => 'get_replay',
  180. 'room_id' => $roomId,
  181. 'start' => $start,
  182. 'limit' => $limit,
  183. ];
  184. return $this->httpPostJson('wxa/business/getliveinfo', $params);
  185. }
  186. /**
  187. * Create a live room.
  188. *
  189. * @param array $params
  190. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  191. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  192. * @throws \GuzzleHttp\Exception\GuzzleException
  193. */
  194. public function createLiveRoom(array $params)
  195. {
  196. return $this->httpPost('wxaapi/broadcast/room/create', $params);
  197. }
  198. /**
  199. * Delete a live room.
  200. *
  201. * @param array $params
  202. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  203. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  204. */
  205. public function deleteLiveRoom(array $params)
  206. {
  207. return $this->httpPost('wxaapi/broadcast/room/deleteroom', $params);
  208. }
  209. /**
  210. * Update a live room.
  211. *
  212. * @param array $params
  213. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  214. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  215. */
  216. public function updateLiveRoom(array $params)
  217. {
  218. return $this->httpPost('wxaapi/broadcast/room/editroom', $params);
  219. }
  220. /**
  221. * Gets the live room push stream url.
  222. *
  223. * @param array $params
  224. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  225. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  226. */
  227. public function getPushUrl(array $params)
  228. {
  229. return $this->httpGet('wxaapi/broadcast/room/getpushurl', $params);
  230. }
  231. /**
  232. * Gets the live room share qrcode.
  233. *
  234. * @param array $params
  235. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  236. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  237. */
  238. public function getShareQrcode(array $params)
  239. {
  240. return $this->httpGet('wxaapi/broadcast/room/getsharedcode', $params);
  241. }
  242. /**
  243. * Add a live room assistant.
  244. *
  245. * @param array $params
  246. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  247. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  248. */
  249. public function addAssistant(array $params)
  250. {
  251. return $this->httpPost('wxaapi/broadcast/room/addassistant', $params);
  252. }
  253. /**
  254. * Update a live room assistant.
  255. *
  256. * @param array $params
  257. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  258. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  259. */
  260. public function updateAssistant(array $params)
  261. {
  262. return $this->httpPost('wxaapi/broadcast/room/modifyassistant', $params);
  263. }
  264. /**
  265. * Delete a live room assistant.
  266. *
  267. * @param array $params
  268. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  269. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  270. */
  271. public function deleteAssistant(array $params)
  272. {
  273. return $this->httpPost('wxaapi/broadcast/room/removeassistant', $params);
  274. }
  275. /**
  276. * Gets the assistant list.
  277. *
  278. * @param array $params
  279. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  280. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  281. */
  282. public function getAssistantList(array $params)
  283. {
  284. return $this->httpGet('wxaapi/broadcast/room/getassistantlist', $params);
  285. }
  286. /**
  287. * Add the sub anchor.
  288. *
  289. * @param array $params
  290. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  291. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  292. */
  293. public function addSubAnchor(array $params)
  294. {
  295. return $this->httpPost('wxaapi/broadcast/room/addsubanchor', $params);
  296. }
  297. /**
  298. * Update the sub anchor.
  299. *
  300. * @param array $params
  301. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  302. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  303. */
  304. public function updateSubAnchor(array $params)
  305. {
  306. return $this->httpPost('wxaapi/broadcast/room/modifysubanchor', $params);
  307. }
  308. /**
  309. * Delete the sub anchor.
  310. *
  311. * @param array $params
  312. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  313. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  314. */
  315. public function deleteSubAnchor(array $params)
  316. {
  317. return $this->httpPost('wxaapi/broadcast/room/deletesubanchor', $params);
  318. }
  319. /**
  320. * Gets the sub anchor info.
  321. *
  322. * @param array $params
  323. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  324. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  325. */
  326. public function getSubAnchor(array $params)
  327. {
  328. return $this->httpGet('wxaapi/broadcast/room/getsubanchor', $params);
  329. }
  330. /**
  331. * Turn official index on/off.
  332. *
  333. * @param array $params
  334. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  335. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  336. */
  337. public function updateFeedPublic(array $params)
  338. {
  339. return $this->httpPost('wxaapi/broadcast/room/updatefeedpublic', $params);
  340. }
  341. /**
  342. * Turn playback status on/off.
  343. *
  344. * @param array $params
  345. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  346. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  347. */
  348. public function updateReplay(array $params)
  349. {
  350. return $this->httpPost('wxaapi/broadcast/room/updatereplay', $params);
  351. }
  352. /**
  353. * Turn customer service status on/off.
  354. *
  355. * @param array $params
  356. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  357. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  358. */
  359. public function updateKf(array $params)
  360. {
  361. return $this->httpPost('wxaapi/broadcast/room/updatekf', $params);
  362. }
  363. /**
  364. * Turn global comments status on/off.
  365. *
  366. * @param array $params
  367. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  368. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  369. */
  370. public function updateComment(array $params)
  371. {
  372. return $this->httpPost('wxaapi/broadcast/room/updatecomment', $params);
  373. }
  374. /**
  375. * Add member role.
  376. *
  377. * @param array $params
  378. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  379. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  380. */
  381. public function addRole(array $params)
  382. {
  383. return $this->httpPost('wxaapi/broadcast/role/addrole', $params);
  384. }
  385. /**
  386. * Delete member role.
  387. *
  388. * @param array $params
  389. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  390. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  391. */
  392. public function deleteRole(array $params)
  393. {
  394. return $this->httpPost('wxaapi/broadcast/role/deleterole', $params);
  395. }
  396. /**
  397. * Gets the role list.
  398. *
  399. * @param array $params
  400. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  401. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  402. */
  403. public function getRoleList(array $params)
  404. {
  405. return $this->httpGet('wxaapi/broadcast/role/getrolelist', $params);
  406. }
  407. /**
  408. * Gets long-term subscribers.
  409. *
  410. * @param array $params
  411. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  412. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  413. * @throws \GuzzleHttp\Exception\GuzzleException
  414. */
  415. public function getFollowers(array $params)
  416. {
  417. return $this->httpPost('wxa/business/get_wxa_followers', $params);
  418. }
  419. /**
  420. * Sending live broadcast start event to long-term subscribers.
  421. *
  422. * @param array $params
  423. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  424. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  425. * @throws \GuzzleHttp\Exception\GuzzleException
  426. */
  427. public function pushMessage(array $params)
  428. {
  429. return $this->httpPost('wxa/business/push_message', $params);
  430. }
  431. /**
  432. * Change the status of goods on/off shelves in room.
  433. *
  434. * @param array $params
  435. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  436. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  437. * @throws \GuzzleHttp\Exception\GuzzleException
  438. */
  439. public function updateGoodsInRoom(array $params)
  440. {
  441. return $this->httpPost('wxaapi/broadcast/goods/onsale', $params);
  442. }
  443. /**
  444. * Delete goods in room.
  445. *
  446. * @param array $params
  447. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  448. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  449. * @throws \GuzzleHttp\Exception\GuzzleException
  450. */
  451. public function deleteGoodsInRoom(array $params)
  452. {
  453. return $this->httpPost('wxaapi/broadcast/goods/deleteInRoom', $params);
  454. }
  455. /**
  456. * Push goods in room.
  457. *
  458. * @param array $params
  459. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  460. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  461. * @throws \GuzzleHttp\Exception\GuzzleException
  462. */
  463. public function pushGoods(array $params)
  464. {
  465. return $this->httpPost('wxaapi/broadcast/goods/push', $params);
  466. }
  467. /**
  468. * Change goods sort in room.
  469. *
  470. * @param array $params
  471. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  472. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  473. * @throws \GuzzleHttp\Exception\GuzzleException
  474. */
  475. public function sortGoods(array $params)
  476. {
  477. return $this->httpPost('wxaapi/broadcast/goods/sort', $params);
  478. }
  479. /**
  480. * Download goods explanation video.
  481. *
  482. * @param array $params
  483. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  484. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  485. * @throws \GuzzleHttp\Exception\GuzzleException
  486. */
  487. public function downloadGoodsExplanationVideo(array $params)
  488. {
  489. return $this->httpPost('wxaapi/broadcast/goods/getVideo', $params);
  490. }
  491. /**
  492. * 获取小程序scheme码
  493. *
  494. * @param array $param
  495. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  496. * @throws \GuzzleHttp\Exception\GuzzleException
  497. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  498. */
  499. public function urlscheme(array $param = [])
  500. {
  501. return $this->httpPostJson('wxa/generatescheme', $param);
  502. }
  503. /**
  504. * 获取小程序 URL Link
  505. *
  506. * @param array $param
  507. * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
  508. * @throws \GuzzleHttp\Exception\GuzzleException
  509. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  510. */
  511. public function urllink(array $param = [])
  512. {
  513. return $this->httpPostJson('wxa/generate_urllink', $param);
  514. }
  515. }