显示Youtube API V3的stdClass对象结果


Array ( [results] => Array ( [0] => stdClass Object ( [kind] => youtube#playlistItem [etag] => "sGDdEsjSJ_SnACpEvVQ6MtTzkrI/Hld9sAU5IF-CaWnmAvvbwdVOmW8" [id] => PLGPyqY_HX5wk4cLJaX50d7Ncr5vEvh2xET5o9rHCUuZo [snippet] => stdClass Object ( [publishedAt] => 2015-09-05T05:58:01.000Z [channelId] => UCufw5B9GPI2ZKXcq0r3GPvg [title] => Intellisense Institute of Technology - Students Quick Talk [description] => Intellisense Institute of Technology - Students Quick Talk [thumbnails] => stdClass Object ( [default] => stdClass Object ( [url] => https://i.ytimg.com/vi/Q9oYREOUAEo/default.jpg [width] => 120 [height] => 90 ) [medium] => stdClass Object ( [url] => https://i.ytimg.com/vi/Q9oYREOUAEo/mqdefault.jpg [width] => 320 [height] => 180 ) [high] => stdClass Object ( [url] => https://i.ytimg.com/vi/Q9oYREOUAEo/hqdefault.jpg [width] => 480 [height] => 360 ) ) [channelTitle] => Bobby Gerez [playlistId] => PL9Rdj0W_2qbNczyMChLB4GNfDrrmNVYd6 [position] => 0 [resourceId] => stdClass Object ( [kind] => youtube#video [videoId] => Q9oYREOUAEo ) ) [contentDetails] => stdClass Object ( [videoId] => Q9oYREOUAEo ) [status] => stdClass Object ( [privacyStatus] => public ) ) [1] => stdClass Object ( [kind] => youtube#playlistItem [etag] => "sGDdEsjSJ_SnACpEvVQ6MtTzkrI/O4GbKescshBt3X2Qd32HOEM168I" [id] => PLGPyqY_HX5wk4cLJaX50d7F9HqUVBzz-yP78l5pCY5hk [snippet] => stdClass Object ( [publishedAt] => 2015-09-05T05:58:01.000Z [channelId] => UCufw5B9GPI2ZKXcq0r3GPvg [title] => Intellisense Institute of Technology - Students Quick Talk [description] => Intellisense Institute of Technology - Students Quick Talk [thumbnails] => stdClass Object ( [default] => stdClass Object ( [url] => https://i.ytimg.com/vi/qqNt3uUC_nU/default.jpg [width] => 120 [height] => 90 ) [medium] => stdClass Object ( [url] => https://i.ytimg.com/vi/qqNt3uUC_nU/mqdefault.jpg [width] => 320 [height] => 180 ) [high] => stdClass Object ( [url] => https://i.ytimg.com/vi/qqNt3uUC_nU/hqdefault.jpg [width] => 480 [height] => 360 ) ) [channelTitle] => Bobby Gerez [playlistId] => PL9Rdj0W_2qbNczyMChLB4GNfDrrmNVYd6 [position] => 1 [resourceId] => stdClass Object ( [kind] => youtube#video [videoId] => qqNt3uUC_nU ) ) [contentDetails] => stdClass Object ( [videoId] => qqNt3uUC_nU ) [status] => stdClass Object ( [privacyStatus] => public ) ) [2] => stdClass Object ( [kind] => youtube#playlistItem [etag] => "sGDdEsjSJ_SnACpEvVQ6MtTzkrI/KwLYVUcNfNgsEdZWk8Ub4oycqVs" [id] => PLGPyqY_HX5wk4cLJaX50d7K2ilGj1zLQkk6B69-lsmbY [snippet] => stdClass Object ( [publishedAt] => 2015-09-05T05:58:01.000Z [channelId] => UCufw5B9GPI2ZKXcq0r3GPvg [title] => Intellisense Institute of Technology - Students Quick Talk [description] => Intellisense Institute of Technology - Students Quick Talk [thumbnails] => stdClass Object ( [default] => stdClass Object ( [url] => https://i.ytimg.com/vi/Y68mvebLIz8/default.jpg [width] => 120 [height] => 90 ) [medium] => stdClass Object ( [url] => https://i.ytimg.com/vi/Y68mvebLIz8/mqdefault.jpg [width] => 320 [height] => 180 ) [high] => stdClass Object ( [url] => https://i.ytimg.com/vi/Y68mvebLIz8/hqdefault.jpg [width] => 480 [height] => 360 ) ) [channelTitle] => Bobby Gerez [playlistId] => PL9Rdj0W_2qbNczyMChLB4GNfDrrmNVYd6 [position] => 2 [resourceId] => stdClass Object ( [kind] => youtube#video [videoId] => Y68mvebLIz8 ) ) [contentDetails] => stdClass Object ( [videoId] => Y68mvebLIz8 ) [status] => stdClass Object ( [privacyStatus] => public ) ) [3] => stdClass Object ( [kind] => youtube#playlistItem [etag] => "sGDdEsjSJ_SnACpEvVQ6MtTzkrI/oxHss_K55L38RyWvBnYGApuo70Q" [id] => PLGPyqY_HX5wk4cLJaX50d7JV7qr-HCuLFHnpjKfMAJW0 [snippet] => stdClass Object ( [publishedAt] => 2015-09-05T05:58:01.000Z [channelId] => UCufw5B9GPI2ZKXcq0r3GPvg [title] => Intellisense Institute of Technology - Students Quick Talk [description] => Intellisense Institute of Technology - Students Quick Talk [thumbnails] => stdClass Object ( [default] => stdClass Object ( [url] => https://i.ytimg.com/vi/QDJWlFidvOA/default.jpg [width] => 120 [height] => 90 ) [medium] => stdClass Object ( [url] => https://i.ytimg.com/vi/QDJWlFidvOA/mqdefault.jpg [width] => 320 [height] => 180 ) [high] => stdClass Object ( [url] => https://i.ytimg.com/vi/QDJWlFidvOA/hqdefault.jpg [width] => 480 [height] => 360 ) [standard] => stdClass Object ( [url] => https://i.ytimg.com/vi/QDJWlFidvOA/sddefault.jpg [width] => 640 [height] => 480 ) [maxres] => stdClass Object ( [url] => https://i.ytimg.com/vi/QDJWlFidvOA/maxresdefault.jpg [width] => 1280 [height] => 720 ) ) [channelTitle] => Bobby Gerez [playlistId] => PL9Rdj0W_2qbNczyMChLB4GNfDrrmNVYd6 [position] => 3 [resourceId] => stdClass Object ( [kind] => youtube#video [videoId] => QDJWlFidvOA ) ) [contentDetails] => stdClass Object ( [videoId] => QDJWlFidvOA ) [status] => stdClass Object ( [privacyStatus] => public ) ) ) )

你可以参考这个网站http://iitcebu.net/video_gallery。问题是如何获得视频。我今天一直在做这个,但我就是做不好。到目前为止这是我的代码

foreach ($playlistItems['results'] as $value){
        foreach($value as $val){
            if(is_object($val)){
                foreach($val as $v){
                    print_r($v);
                    echo "<hr />";
                }
            }
        }        
    }

我甚至不能到达videoId。

我已经成功地管理了Youtube API v3中的stdClass对象。这是我输出视频oid的代码。希望对你有所帮助。

$count = count($playlistItems['results']);
    for($i = 0; $i <= $count-1; $i++){
        $items = $playlistItems['results'][$i]->snippet->resourceId;
        $resourceId = count($items);
        for($x = 0; $x <= $resourceId-1; $x++){
            echo $items->videoId;
            echo "<hr />";
        }
    }

最新更新