Skip to content

Instantly share code, notes, and snippets.

@39ff
Last active March 16, 2019 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 39ff/ba465fa7ed57325cb7fbe27f2f7db190 to your computer and use it in GitHub Desktop.
Save 39ff/ba465fa7ed57325cb7fbe27f2f7db190 to your computer and use it in GitHub Desktop.
<?php
$access = 'x';
$spotifyURL = 'https://api.spotify.com/v1/playlists/37i9dQZF1DWVqfgj8NZEp1';
$ch = curl_init();
$headers = [
'Accept: application/json',
'Content-Type: application/json',
'Authorization: Bearer '.$access
];
curl_setopt($ch, CURLOPT_URL, $spotifyURL);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
//var_dump($response);
//データでかすぎてCLIに表示されないので確認用に保存
file_put_contents('spotify-playlists-test.json',$response);
$json = json_decode($response);
curl_close($ch);
echo $json->description.PHP_EOL;
echo $json->name.PHP_EOL;
//echo '<pre>'.print_r($json, true).'</pre>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment