[PHP][Youtube api v3] retrieving the informations for a single video -


i'm getting trouble youtube api. retrieve informations single video.

what got :

i can videos specified playlist informations (like title, description etc)

i id playlist url :

$playlist = $_get['pl']; 

then videos informations playlist :

$response = $youtube->playlistitems->listplaylistitems('id,snippet,contentdetails', ['playlistid' => $playlist, 'maxresults' => '10']); 

then can , show informations videos foreach :

foreach($response['items'] $video){ echo $video['contentdetails']['videoid'];  echo $video['snippet']['title']; echo substr($video['snippet']['description'], 0, 430);} 

what want :

now put videoid link :

href="index.php?requ=video&v=<?= $video['contentdetails']['videoid']; ?>&pl=<?= $playlist ?>"

this way can videoid other page in embed video :

$vid = $_get['v']; <iframe height ="432" width="760"  src="https://www.youtube.com/embed/<?= $vid; ?>"></iframe> 

but here comes problem, can't informations video, when try :

$viewing = $youtube->videos->listvideos("snippet", ['id' => $vid]); echo $viewing['snippet']['title']; 

it returns me null

if can me bit, awesome

i found solution on own.

as want retrieve information list of videos (even if in case list composed of 1 element), had use foreach retrieve :

<?php foreach($viewing['items'] $view): ?>                         <p><h3><?= $view['snippet']['title']; ?></h3></p>                         <p><?= substr($view['snippet']['description'], 0, 430); ?></p>                         <?php endforeach; ?> 

hope can help


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -