I have this object in php. I must get values from it: title, description, image and player.
stdClass Object
(
[kind] => youtube#video
[etag] => "XI7nbFXulYBIpL0ayR_gDh3eu1k/-GCbscHL0lMNUZAFRWbHsd8S28w"
[id] => QNNNL6PxmmM
[snippet] => stdClass Object
(
[publishedAt] => 2017-07-26T08:43:49.000Z
[channelId] => UCuX-ePmTx8oGhDQ8LKPPGuw
[title] => Wielki Przejazd Rowerowy w duar (11 czerwca 2017)
[description] => Więcej informacji: http://duara.eu/2017/06/12/kolejny-rekord-wielkiego-przejazdu-rowerowego/
[thumbnails] => stdClass Object
(
[default] => stdClass Object
(
[url] => https://i.ytimg.com/vi/QNNNL6PxmmM/default.jpg
[width] => 120
[height] => 90
)
[medium] => stdClass Object
(
[url] => https://i.ytimg.com/vi/QNNNL6PxmmM/mqdefault.jpg
[width] => 320
[height] => 180
)
[high] => stdClass Object
(
[url] => https://i.ytimg.com/vi/QNNNL6PxmmM/hqdefault.jpg
[width] => 480
[height] => 360
)
)
[channelTitle] => Miasto duara
[tags] => Array
(
[0] => Wielki Przejazd Rowerowy w duar
[1] => Wielki Przejazd Rowerowy
[2] => Rowery
[3] => rowery duara
[4] => pasieczny
)
[categoryId] => 25
[liveBroadcastContent] => none
[localized] => stdClass Object
(
[title] => Wielki Przejazd Rowerowy w duar (11 czerwca 2017)
[description] => Więcej informacji: http://duara.eu/2017/06/12/kolejny-rekord-wielkiego-przejazdu-rowerowego/
)
[defaultAudioLanguage] => pl
)
[contentDetails] => stdClass Object
(
[duration] => PT1M50S
[dimension] => 2d
[definition] => hd
[caption] => false
[licensedContent] =>
[projection] => rectangular
)
[status] => stdClass Object
(
[uploadStatus] => processed
[privacyStatus] => public
[license] => youtube
[embeddable] => 1
[publicStatsViewable] =>
)
[statistics] => stdClass Object
(
[viewCount] => 35
[favoriteCount] => 0
[commentCount] => 0
)
[player] => stdClass Object
(
[embedHtml] => <iframe width="480" height="270" src="//www.youtube.com/embed/QNNNL6PxmmM" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
)
)
I want print on screen from this object this values: title, description, image and player?
I try this code:
showVideoDetails = $youtube->getVideoInfo('b2wvZf7ztxA');
foreach ($showVideoDetails as $player) {
echo "XX".$showVideoDetails->snippet->title . PHP_EOL."<br/>";
echo $player->snippet->description . PHP_EOL."<br/>";
echo $player->snippet->thumbnails->maxres->url . PHP_EOL."<br/>";
echo $player->player . PHP_EOL."<br/><br/><br/>";
}
but I have error:
Notice: Trying to get property 'snippet' of non-object in /Applications/XAMPP/xamppfiles/htdocs/madcoda/index.php on line 29
Notice: Trying to get property 'description' of non-object in /Applications/XAMPP/xamppfiles/htdocs/madcoda/index.php on line 29
Notice: Trying to get property 'snippet' of non-object in /Applications/XAMPP/xamppfiles/htdocs/madcoda/index.php on line 30
Notice: Trying to get property 'thumbnails' of non-object in /Applications/XAMPP/xamppfiles/htdocs/madcoda/index.php on line 30
Notice: Trying to get property 'high' of non-object in /Applications/XAMPP/xamppfiles/htdocs/madcoda/index.php on line 30
Notice: Trying to get property 'url' of non-object in /Applications/XAMPP/xamppfiles/htdocs/madcoda/index.php on line 30
Notice: Trying to get property 'player' of non-object in /Applications/XAMPP/xamppfiles/htdocs/madcoda/index.php on line 31
I suspect there is an error in my foreach function. Sorry I'm beginner in php. I need solution in this code to learn.
How repair it?
Thank you for yours help