Live.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 Live
  20. * @package WeMini
  21. */
  22. class Live 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 create($data)
  32. {
  33. $url = 'https://api.weixin.qq.com/wxaapi/broadcast/room/create?access_token=ACCESS_TOKEN';
  34. return $this->callPostApi($url, $data, true);
  35. }
  36. /**
  37. * 获取直播房间列表
  38. * @param integer $start 起始拉取房间
  39. * @param integer $limit 每次拉取的个数上限
  40. * @return array
  41. * @throws \WeChat\Exceptions\InvalidResponseException
  42. * @throws \WeChat\Exceptions\LocalCacheException
  43. */
  44. public function getLiveList($start = 0, $limit = 10)
  45. {
  46. $url = 'https://api.weixin.qq.com/wxa/business/getliveinfo?access_token=ACCESS_TOKEN';
  47. return $this->callPostApi($url, ['start' => $start, 'limit' => $limit], true);
  48. }
  49. /**
  50. * 获取回放源视频
  51. * @param array $data
  52. * @return array
  53. * @throws \WeChat\Exceptions\InvalidResponseException
  54. * @throws \WeChat\Exceptions\LocalCacheException
  55. */
  56. public function getLiveInfo($data = [])
  57. {
  58. $url = 'https://api.weixin.qq.com/wxa/business/getliveinfo?access_token=ACCESS_TOKEN';
  59. return $this->callPostApi($url, $data, true);
  60. }
  61. /**
  62. * 直播间导入商品
  63. * @param array $data
  64. * @return array
  65. * @throws \WeChat\Exceptions\InvalidResponseException
  66. * @throws \WeChat\Exceptions\LocalCacheException
  67. */
  68. public function addLiveGoods($data = [])
  69. {
  70. $url = 'https://api.weixin.qq.com/wxaapi/broadcast/room/addgoods?access_token=ACCESS_TOKEN';
  71. return $this->callPostApi($url, $data, true);
  72. }
  73. /**
  74. * 商品添加并提审
  75. * @param array $data
  76. * @return array
  77. * @throws \WeChat\Exceptions\InvalidResponseException
  78. * @throws \WeChat\Exceptions\LocalCacheException
  79. */
  80. public function addGoods($data)
  81. {
  82. $url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/add?access_token=ACCESS_TOKEN";
  83. return $this->callPostApi($url, $data, true);
  84. }
  85. /**
  86. * 商品撤回审核
  87. * @param array $data
  88. * @return array
  89. * @throws \WeChat\Exceptions\InvalidResponseException
  90. * @throws \WeChat\Exceptions\LocalCacheException
  91. */
  92. public function resetAuditGoods($data)
  93. {
  94. $url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/resetaudit?access_token=ACCESS_TOKEN";
  95. return $this->callPostApi($url, $data, true);
  96. }
  97. /**
  98. * 重新提交审核
  99. * @param array $data
  100. * @return array
  101. * @throws \WeChat\Exceptions\InvalidResponseException
  102. * @throws \WeChat\Exceptions\LocalCacheException
  103. */
  104. public function auditGoods($data)
  105. {
  106. $url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/audit?access_token=ACCESS_TOKEN";
  107. return $this->callPostApi($url, $data, true);
  108. }
  109. /**
  110. * 删除商品
  111. * @param array $data
  112. * @return array
  113. * @throws \WeChat\Exceptions\InvalidResponseException
  114. * @throws \WeChat\Exceptions\LocalCacheException
  115. */
  116. public function deleteGoods($data)
  117. {
  118. $url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/delete?access_token=ACCESS_TOKEN";
  119. return $this->callPostApi($url, $data, true);
  120. }
  121. /**
  122. * 更新商品
  123. * @param array $data
  124. * @return array
  125. * @throws \WeChat\Exceptions\InvalidResponseException
  126. * @throws \WeChat\Exceptions\LocalCacheException
  127. */
  128. public function updateGoods($data)
  129. {
  130. $url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/update?access_token=ACCESS_TOKEN";
  131. return $this->callPostApi($url, $data, true);
  132. }
  133. /**
  134. * 获取商品状态
  135. * @param array $data
  136. * @return array
  137. * @throws \WeChat\Exceptions\InvalidResponseException
  138. * @throws \WeChat\Exceptions\LocalCacheException
  139. */
  140. public function stateGoods($data)
  141. {
  142. $url = "https://api.weixin.qq.com/wxa/business/getgoodswarehouse?access_token=ACCESS_TOKEN";
  143. return $this->callPostApi($url, $data, true);
  144. }
  145. /**
  146. * 获取商品列表
  147. * @param array $data
  148. * @return array
  149. * @throws \WeChat\Exceptions\InvalidResponseException
  150. * @throws \WeChat\Exceptions\LocalCacheException
  151. */
  152. public function getGoods($data)
  153. {
  154. $url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/getapproved?access_token=ACCESS_TOKEN";
  155. return $this->callPostApi($url, $data, true);
  156. }
  157. }