Mensur Mensur - 3 months ago 14
PHP Question

Get song information from soundcloud, having song id

I'm having song id's stored from Soundcloud but I would like to fetch information from Soundcloud from these songid:s.

How do I get the song name, artist, cover from artists using PHP?

Anyone having any examples maybe? All help would be appriciated.

Answer

To get song information from SoundCloud sending a GET request to their API should work fine.

CURL

$ curl "http://api.soundcloud.com/tracks/{track_id}?client_id={YOUR_CLIENT_ID}"

PHP

<?php

// Get cURL resource
$curl = curl_init();

// Set some options
curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL => 'http://api.soundcloud.com/tracks/{track_id}?client_id={YOUR_CLIENT_ID}'
));

// Send the request & save response to $resp
$resp = curl_exec($curl);

// Close request to clear up some resources
curl_close($curl);

?>

API reference - https://developers.soundcloud.com/docs/api/reference#tracks

Comments