0
votes

I want to use api V3 of youtube for get last video of a channel.

When i try in php, i can't get "videoId"

<?php
$url = "https://www.googleapis.com/youtube/v3/playlistItems?          part=snippet&maxResults=1&playlistId=XX&key=XX";
 $obj = json_decode($json);
 print $json_output->{'snippet'}->{'ressourceId'}->{'videoId'};
?>

that didn't print anithing.

Can you help me pls. thank you

edit : url : https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=1&playlistId=PLcsF2yXOMjK-nfdafvV3pNPY6Va28y5p1&key=AIzaSyBpu8hgnXbkqFVWrAvwRUEz7T13ii3I7WM

1
have you tried print $json_output->snippe->resourceId->videoId;Satya
yes, but that didn't work too ='(Argardor
can i know how to get url valueRamki

1 Answers

0
votes
$json = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=1&playlistId=PLcsF2yXOMjK-nfdafvV3pNPY6Va28y5p1&key=AIzaSyBpu8hgnXbkqFVWrAvwRUEz7T13ii3I7WM";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,$json);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        $result=curl_exec($ch);
        curl_close($ch);
        echo "<pre>";
        print_r(json_decode($result,true));
        echo "</pre>";

use like this to get the Data