laravel 4 - Retrieving Thumbnail and Video Time Using Youtube API V3 in PHP -


i followed tut https://packagist.org/packages/alaouy/youtube

and got alright have problem in snippet:

$video = youtube::getvideoinfo('rie-hpvj7sw'); var_dump($video); 

this response get:

object(stdclass)#712 (8) { ["kind"]=> string(13) "youtube#video" ["etag"]=> string(57) ""idqj1j7zks4x3o3zsflbowgwahu/xcpzrqbmtpmepymbsgq0oz6nle4"" ["id"]=> string(11) "rie-hpvj7sw" ["snippet"]=> object(stdclass)#713 (10) { ["publishedat"]=> string(24) "2013-03-21t02:28:12.000z" ["channelid"]=> string(24) "uc5enzai7preahgw1hpgoqeq" ["title"]=> string(48) "sergey brin talks google glass @ ted 2013" ["description"]=> string(479) "update: address comments sergey's poor delivery, want emphasize not "ted talk", despite being recorded during ted conference. pretty spontaneous appearance show latest technology , wasn't prepared or rehearsed. google glass not available purchase yet not strictly speaking product promotion either. video posted because has details glass unknown or unconfirmed before." ["thumbnails"]=> object(stdclass)#714 (3) { ["default"]=> object(stdclass)#715 (3) { ["url"]=> string(46) "https://i.ytimg.com/vi/rie-hpvj7sw/default.jpg" ["width"]=> int(120) ["height"]=> int(90) } ["medium"]=> object(stdclass)#716 (3) { ["url"]=> string(48) "https://i.ytimg.com/vi/rie-hpvj7sw/mqdefault.jpg" ["width"]=> int(320) ["height"]=> int(180) } ["high"]=> object(stdclass)#717 (3) { ["url"]=> string(48) "https://i.ytimg.com/vi/rie-hpvj7sw/hqdefault.jpg" ["width"]=> int(480) ["height"]=> int(360) } } ["channeltitle"]=> string(8) "tedleaks" ["tags"]=> array(4) { [0]=> string(11) "sergey brin" [1]=> string(6) "google" [2]=> string(12) "google glass" [3]=> string(3) "ted" } ["categoryid"]=> string(2) "28" ["livebroadcastcontent"]=> string(4) "none" ["localized"]=> object(stdclass)#718 (2) { ["title"]=> string(48) "sergey brin talks google glass @ ted 2013" ["description"]=> string(479) "update: address comments sergey's poor delivery, want emphasize not "ted talk", despite being recorded during ted conference. pretty spontaneous appearance show latest technology , wasn't prepared or rehearsed. google glass not available purchase yet not strictly speaking product promotion either. video posted because has details glass unknown or unconfirmed before." } } ["contentdetails"]=> object(stdclass)#719 (5) { ["duration"]=> string(8) "pt13m30s" ["dimension"]=> string(2) "2d" ["definition"]=> string(2) "sd" ["caption"]=> string(5) "false" ["licensedcontent"]=> bool(false) } ["status"]=> object(stdclass)#720 (5) { ["uploadstatus"]=> string(9) "processed" ["privacystatus"]=> string(6) "public" ["license"]=> string(7) "youtube" ["embeddable"]=> bool(true) ["publicstatsviewable"]=> bool(true) } ["statistics"]=> object(stdclass)#721 (5) { ["viewcount"]=> string(6) "539812" ["likecount"]=> string(4) "2450" ["dislikecount"]=> string(3) "371" ["favoritecount"]=> string(1) "0" ["commentcount"]=> string(4) "2247" } ["player"]=> object(stdclass)#722 (1) { ["embedhtml"]=> string(116) "

sorry long output line.

what after video duration time, thumbnail , title of video.

i guess should in form this.

<?php   foreach($item $video)    {     echo $item['snippet']['thumbnails]['default'];    } ?> 

something keeps throwing errors.

it's stdclass, not array. correct way info be

<?php     $video = youtube::getvideoinfo('rie-hpvj7sw');     echo $video->snippet->thumbnails->default->url; ?> 

Comments