php - 没有通过 Google_Service_YouTube 进行直播(google/apiclient)
问题描述
我正在尝试将 YouTube(视频和直播)整合到我们的媒体网站中。我正在使用,基于 PHP,google/apiclient:^2.0
到目前为止,我通过 OAuth 成功完成了身份验证和授权,并检索了已在我的 Google/Youtube 用户的相应频道中上传的点播视频列表。即使在不重复强制登录的情况下管理离线访问也有效。
尽管如此,检索当前的直播流,而且我必须强调该流是活跃的并且可以在 Youtube 的仪表板中观看,是行不通的。直播源通过 Wowza 4.7 推送到 Youtube,运行完美。
这是负责获取数据的代码片段:
public function livestreams()
{
try {
$this->_loadToken();
$this->setService(new \Google_Service_YouTube($this->getClient()));
$streamsResponse = $this->getService()->liveStreams->listLiveStreams('id,snippet', array(
'mine' => 'true',
));
} catch (\Exception $e) {
\Log::error($e->getMessage());
return [];
}
return $streamsResponse;
}
此查询的结果:
Google_Service_YouTube_LiveStreamListResponse {#416 ▼
#collection_key: "items"
+etag: ""XXXXXXXX""
+eventId: null
#itemsType: "Google_Service_YouTube_LiveStream"
#itemsDataType: "array"
+kind: "youtube#liveStreamListResponse"
+nextPageToken: null
#pageInfoType: "Google_Service_YouTube_PageInfo"
#pageInfoDataType: ""
+prevPageToken: null
#tokenPaginationType: "Google_Service_YouTube_TokenPagination"
#tokenPaginationDataType: ""
+visitorId: null
#internal_gapi_mappings: []
#modelData: []
#processed: []
+"pageInfo": Google_Service_YouTube_PageInfo {#417 ▶}
+"items": []
}
所以items
是空的,而我希望能找到一个项目,即我推送到 YouTube 的当前活跃且可观看的直播流。
这是 API 中的一个缺陷,还是我这边存在根本性的误解?
解决方案
推荐阅读
- c++ - 如何从可以在所有平台上运行的 C 或 C++ 系统中获取当前本地格式日期
- c++ - 在 C++ 中创建一个要在 C# 中使用的 dll
- terraform - 使用 for_each 使用列表输入创建多个磁盘及其快照
- java - 使用休眠将三个表合并为一个
- postgresql - MAKE_INTERVAL 语法
- c# - 来自 JSON 属性的默认数值,带有空字符串
- java - Android - 将日期格式更改为 dd/mm/yy
- javascript - 延迟加载外部javascript
- python - Python BeautifulSoup汽车排名抓取
- xml - 使用 XSLT 根据条件文本之间的位置添加逗号(,)或“或”