Live.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | WeChatDeveloper
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2022 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: https://thinkadmin.top
  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. return $this->callPostApi($url, $data, true);
  33. }
  34. /**
  35. * 获取直播房间列表
  36. * @param integer $start 起始拉取房间
  37. * @param integer $limit 每次拉取的个数上限
  38. * @return array
  39. * @throws \WeChat\Exceptions\InvalidResponseException
  40. * @throws \WeChat\Exceptions\LocalCacheException
  41. */
  42. public function getLiveList($start = 0, $limit = 10)
  43. {
  44. $url = 'https://api.weixin.qq.com/wxa/business/getliveinfo?access_token=ACCESS_TOKEN';
  45. return $this->callPostApi($url, ['start' => $start, 'limit' => $limit], true);
  46. }
  47. /**
  48. * 获取回放源视频
  49. * @param array $data
  50. * @return array
  51. * @throws \WeChat\Exceptions\InvalidResponseException
  52. * @throws \WeChat\Exceptions\LocalCacheException
  53. */
  54. public function getLiveInfo($data = [])
  55. {
  56. $url = 'https://api.weixin.qq.com/wxa/business/getliveinfo?access_token=ACCESS_TOKEN';
  57. return $this->callPostApi($url, $data, true);
  58. }
  59. /**
  60. * 直播间导入商品
  61. * @param array $data
  62. * @return array
  63. * @throws \WeChat\Exceptions\InvalidResponseException
  64. * @throws \WeChat\Exceptions\LocalCacheException
  65. */
  66. public function addLiveGoods($data = [])
  67. {
  68. $url = 'https://api.weixin.qq.com/wxaapi/broadcast/room/addgoods?access_token=ACCESS_TOKEN';
  69. return $this->callPostApi($url, $data, true);
  70. }
  71. /**
  72. * 商品添加并提审
  73. * @param array $data
  74. * @return array
  75. * @throws \WeChat\Exceptions\InvalidResponseException
  76. * @throws \WeChat\Exceptions\LocalCacheException
  77. */
  78. public function addGoods($data)
  79. {
  80. $url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/add?access_token=ACCESS_TOKEN";
  81. return $this->callPostApi($url, $data, true);
  82. }
  83. /**
  84. * 商品撤回审核
  85. * @param array $data
  86. * @return array
  87. * @throws \WeChat\Exceptions\InvalidResponseException
  88. * @throws \WeChat\Exceptions\LocalCacheException
  89. */
  90. public function resetAuditGoods($data)
  91. {
  92. $url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/resetaudit?access_token=ACCESS_TOKEN";
  93. return $this->callPostApi($url, $data, true);
  94. }
  95. /**
  96. * 重新提交审核
  97. * @param array $data
  98. * @return array
  99. * @throws \WeChat\Exceptions\InvalidResponseException
  100. * @throws \WeChat\Exceptions\LocalCacheException
  101. */
  102. public function auditGoods($data)
  103. {
  104. $url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/audit?access_token=ACCESS_TOKEN";
  105. return $this->callPostApi($url, $data, true);
  106. }
  107. /**
  108. * 删除商品
  109. * @param array $data
  110. * @return array
  111. * @throws \WeChat\Exceptions\InvalidResponseException
  112. * @throws \WeChat\Exceptions\LocalCacheException
  113. */
  114. public function deleteGoods($data)
  115. {
  116. $url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/delete?access_token=ACCESS_TOKEN";
  117. return $this->callPostApi($url, $data, true);
  118. }
  119. /**
  120. * 更新商品
  121. * @param array $data
  122. * @return array
  123. * @throws \WeChat\Exceptions\InvalidResponseException
  124. * @throws \WeChat\Exceptions\LocalCacheException
  125. */
  126. public function updateGoods($data)
  127. {
  128. $url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/update?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 stateGoods($data)
  139. {
  140. $url = "https://api.weixin.qq.com/wxa/business/getgoodswarehouse?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 getGoods($data)
  151. {
  152. $url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/getapproved?access_token=ACCESS_TOKEN";
  153. return $this->callPostApi($url, $data, true);
  154. }
  155. }