用于PHP的Youtube数据API - 没有得到任何" publishAt"值

时间:2015-07-23 13:16:25

标签: php youtube youtube-api youtube-data-api

我希望在预定的发布日期跟踪我上传的视频。我确实收到了上传的视频,并通过 privacyStatus " private"但我没有获得任何 publishAt 值。

我做错了什么?!

    // Call the channels.list method to retrieve information about the
    // currently authenticated user's channel.
    $channelsResponse = $youtube->channels->listChannels('contentDetails', array( 'mine' => 'true'));

    $htmlBody = '';
    foreach ($channelsResponse['items'] as $channel) {
        // Extract the unique playlist ID that identifies the list of videos
        // uploaded to the channel, and then call the playlistItems.list method
        // to retrieve that list.
        $uploadsListId = $channel['contentDetails']['relatedPlaylists']['uploads'];

        $playlistItemsResponse = $youtube->playlistItems->listPlaylistItems('snippet', array(
            'playlistId' => $uploadsListId,
            'maxResults' => 50
        ));

        $htmlBody .= "<h3>Planned Videos</h3><ul>"; //Videos in list $uploadsListId
        foreach ($playlistItemsResponse['items'] as $playlistItem) {      

            $listResponse = $youtube->videos->listVideos('status', array('id' => $playlistItem['snippet']['resourceId']['videoId']));
            $video = $listResponse[0];
            $videoStatus = $video['status'];

            // Just print private videos
            if ($videoStatus->privacyStatus == 'private') {         
                $htmlBody .= sprintf('<li>%s (%s)</li>', $playlistItem['snippet']['title'], $videoStatus['publishAt']);
            }
        }
        $htmlBody .= '</ul>';
    }

0 个答案:

没有答案