gpt4 book ai didi

php - Youtube API v3-获取视频网址

转载 作者:行者123 更新时间:2023-12-03 06:28:26 25 4
gpt4 key购买 nike

我正在通过Youtube API v3将视频上传到我的 channel 。我想将这些视频自动嵌入到我的网站中,所以我想在上传后立即将视频链接或嵌入代码保存在我的数据库中。

以这种方式上载视频时,具有以下特征的视频资源对象将返回:

https://developers.google.com/youtube/v3/docs/videos

但是当我尝试检索这些数据时,是完全不完整的。

我究竟做错了什么?还有其他方法至少可以获取视频网址吗?因为在视频对象引用中它不会出现此特征。

这是返回对象的var_dump:

object(Google_Service_YouTube_Video)#639 (35) { ["ageGatingType":protected]=> string(37) "Google_Service_YouTube_VideoAgeGating" ["ageGatingDataType":protected]=> string(0) "" ["contentDetailsType":protected]=> string(42) "Google_Service_YouTube_VideoContentDetails" ["contentDetailsDataType":protected]=> string(0) "" ["conversionPingsType":protected]=> string(43) "Google_Service_YouTube_VideoConversionPings" ["conversionPingsDataType":protected]=> string(0) "" ["etag"]=> string(57) ""OilNCqKLXpFjeQ5CI-_BZqeMuCo/YPCGdIxr3w1vom2ktjPNSjPvFz4"" ["fileDetailsType":protected]=> string(39) "Google_Service_YouTube_VideoFileDetails" ["fileDetailsDataType":protected]=> string(0) "" ["id"]=> string(11) "-RbO_K6wgt4" ["kind"]=> string(13) "youtube#video" ["liveStreamingDetailsType":protected]=> string(48) "Google_Service_YouTube_VideoLiveStreamingDetails" ["liveStreamingDetailsDataType":protected]=> string(0) "" ["monetizationDetailsType":protected]=> string(47) "Google_Service_YouTube_VideoMonetizationDetails" ["monetizationDetailsDataType":protected]=> string(0) "" ["playerType":protected]=> string(34) "Google_Service_YouTube_VideoPlayer" ["playerDataType":protected]=> string(0) "" ["processingDetailsType":protected]=> string(45) "Google_Service_YouTube_VideoProcessingDetails" ["processingDetailsDataType":protected]=> string(0) "" ["projectDetailsType":protected]=> string(42) "Google_Service_YouTube_VideoProjectDetails" ["projectDetailsDataType":protected]=> string(0) "" ["recordingDetailsType":protected]=> string(44) "Google_Service_YouTube_VideoRecordingDetails" ["recordingDetailsDataType":protected]=> string(0) "" ["snippetType":protected]=> string(35) "Google_Service_YouTube_VideoSnippet" ["snippetDataType":protected]=> string(0) "" ["statisticsType":protected]=> string(38) "Google_Service_YouTube_VideoStatistics" ["statisticsDataType":protected]=> string(0) "" ["statusType":protected]=> string(34) "Google_Service_YouTube_VideoStatus" ["statusDataType":protected]=> string(0) "" ["suggestionsType":protected]=> string(39) "Google_Service_YouTube_VideoSuggestions" ["suggestionsDataType":protected]=> string(0) "" ["topicDetailsType":protected]=> string(40) "Google_Service_YouTube_VideoTopicDetails" ["topicDetailsDataType":protected]=> string(0) "" ["data":protected]=> array(2) { ["snippet"]=> array(9) { ["publishedAt"]=> string(24) "2014-04-21T13:48:06.000Z" ["channelId"]=> string(24) "UCg1bpF8UvsR8iEtZp0X82mw" ["title"]=> string(3) "vdz" ["description"]=> string(8) "vdavvvvv" ["thumbnails"]=> array(3) { ["default"]=> array(1) { ["url"]=> string(47) "https://i1.ytimg.com/vi/-RbO_K6wgt4/default.jpg" } ["medium"]=> array(1) { ["url"]=> string(49) "https://i1.ytimg.com/vi/-RbO_K6wgt4/mqdefault.jpg" } ["high"]=> array(1) { ["url"]=> string(49) "https://i1.ytimg.com/vi/-RbO_K6wgt4/hqdefault.jpg" } } ["channelTitle"]=> string(7) "Twinkle" ["tags"]=> array(2) { [0]=> string(4) "tag1" [1]=> string(4) "tag2" } ["categoryId"]=> string(2) "22" ["liveBroadcastContent"]=> string(4) "none" } ["status"]=> array(5) { ["uploadStatus"]=> string(8) "uploaded" ["privacyStatus"]=> string(6) "public" ["license"]=> string(7) "youtube" ["embeddable"]=> bool(true) ["publicStatsViewable"]=> bool(true) } } ["processed":protected]=> array(0) { } }

最佳答案

错误是在执行请求时。我从示例中获取了代码:

$insertRequest = $youtube->videos->insert("status,snippet", $video);

“插入”方法的第一个参数定义将修改视频对象的哪些部分以及您希望在响应中检索哪些部分。

因此解决方案更改为:
$insertRequest = $youtube->videos->insert("status,snippet,player", $video);

关于php - Youtube API v3-获取视频网址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23198945/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com