This repository has been archived on 2024-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
yoshop/source/application/common/library/wechat/live/Room.php
2020-08-28 10:35:48 +08:00

43 lines
1.3 KiB
PHP

<?php
namespace app\common\library\wechat\live;
use app\common\library\wechat\WxBase;
/**
* 微信小程序直播接口
* Class Room
* @package app\common\library\wechat\live
*/
class Room extends WxBase
{
/**
* 微信小程序直播-获取直播房间列表接口
* api文档: https://developers.weixin.qq.com/miniprogram/dev/framework/liveplayer/live-player-plugin.html
* @throws \app\common\exception\BaseException
*/
public function getLiveRoomList()
{
// 微信接口url
$accessToken = $this->getAccessToken();
$apiUrl = "http://api.weixin.qq.com/wxa/business/getliveinfo?access_token={$accessToken}";
// 请求参数
$params = $this->jsonEncode(['start' => 0, 'limit' => 100]);
// 执行请求
$result = $this->post($apiUrl, $params);
// 记录日志
$this->doLogs(['describe' => '微信小程序直播-获取直播房间列表接口', 'url' => $apiUrl, 'params' => $params, 'result' => $result]);
// 返回结果
$response = $this->jsonDecode($result);
if (!isset($response['errcode'])) {
$this->error = 'not found errcode';
return false;
}
if ((int)$response['errcode'] > 1) {
$this->error = $response['errmsg'];
return false;
}
return $response;
}
}