m try to fetch the pagination from json but my hand off now so anyone can complete the pagination result from it youtube api v3
PHP Code:
<?php $url="https://www.googleapis.com/youtube/v3/search?order=rating&part=snippet&q=cars&maxResults=10&key=AIzaSyBCLxHPgsISSgx0asL7dBit5u-1NIfFX3w&pageToken"; $curl = curl_init($url); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_HTTPHEADER, $curlheader); $json_response = curl_exec($curl); curl_close($curl); $result = json_decode($json_response, true); foreach ($result['items'] as $data ){ $vtittle = $data['snippet']['title']; $vid = $data['id']['videoId']; $videoThumb = $data['snippet']['thumbnails']['default']['url']; print'<br>'.$vtittle.'<br><img src="'.$videoThumb.'" /><br>'.$vid.''; } ?>
Comment