ProgramWechatLive.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace crmeb\services\wechatlive;
  3. use EasyWeChat\Core\AbstractAPI;
  4. use EasyWeChat\Core\AccessToken;
  5. use EasyWeChat\Core\Exceptions\InvalidArgumentException;
  6. /**
  7. * Class ProgramWechatLive
  8. * @package crmeb\services\wechatlive
  9. */
  10. class ProgramWechatLive extends AbstractAPI
  11. {
  12. /**
  13. * 获取直播列表信息
  14. */
  15. const API_WECHAT_LIVE = 'https://api.weixin.qq.com/wxa/business/getliveinfo';
  16. /**
  17. * ProgramWechatLive constructor.
  18. * @param AccessToken $accessToken
  19. */
  20. public function __construct(AccessToken $accessToken)
  21. {
  22. parent::__construct($accessToken);
  23. }
  24. /**
  25. * 获取直播间列表
  26. * @param int $page
  27. * @param int $limit
  28. * @return \EasyWeChat\Support\Collection|null
  29. * @throws \EasyWeChat\Core\Exceptions\HttpException
  30. */
  31. public function getLiveInfo(int $page = 1, int $limit = 10)
  32. {
  33. $page = ($page - 1) * $limit;
  34. $params = [
  35. 'start' => $page,
  36. 'limit' => $limit
  37. ];
  38. return $this->parseJSON('json', [self::API_WECHAT_LIVE, $params]);
  39. }
  40. }