Live.php 6.1 KB

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