mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-30 20:20:53 +00:00
26 lines
619 B
PHP
26 lines
619 B
PHP
<?php
|
|
require __DIR__ . '/vendor/autoload.php';
|
|
|
|
use \Curl\Curl;
|
|
|
|
define('YOUTUBE_API_KEY', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
|
|
|
|
$playlistId = 'RDHJb0VYVtaNc';
|
|
|
|
$curl = new Curl();
|
|
$curl->get('https://www.googleapis.com/youtube/v3/playlistItems', array(
|
|
'key' => YOUTUBE_API_KEY,
|
|
'maxResults' => '50',
|
|
'part' => 'snippet',
|
|
'playlistId' => $playlistId,
|
|
));
|
|
|
|
echo 'Songs in this playlist:' . "\n";
|
|
|
|
foreach ($curl->response->items as $item) {
|
|
echo
|
|
$item->snippet->title . "\n" .
|
|
'https://www.youtube.com/watch?v=' . $item->snippet->resourceId->videoId . "\n" .
|
|
"\n";
|
|
}
|