I use the following code to get data from a specific record from discogs:
//initialize the session
$ch = curl_init();
//Set the User-Agent Identifier
curl_setopt($ch, CURLOPT_USERAGENT, 'MYAPPNAME/0.1 +http://ymysite.com');
//Set the URL of the page or file to download.
curl_setopt($ch, CURLOPT_URL, $url);
//Ask cURL to return the contents in a variable instead of simply echoing them
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//Execute the curl session
$output = curl_exec($ch);
//close the session
curl_close ($ch);
I can echo $output which will give me a very complex output:
{"styles": ["Blues Rock", "Rock & Roll"], "videos": [{"duration": 200, "embed": true, "title": "The Rolling Stones - Street Fighting Man", "description": "The Rolling Stones - Street Fighting Man", "uri": "http://www.youtube.com/watch?v=qUO8ScYVeDo"}, {"duration": 2457, "embed": true, "title": "The Rolling Stones - Beggars Banquet FULL ALBUM (mono vinyl mix)", "description": "The Rolling Stones - Beggars Banquet FULL ALBUM (mono vinyl mix)", "uri": "http://www.youtube.com/watch?v=sRu88xttBrA"}], "series": [], "labels": [{"resource_url": "http://api.discogs.com/labels/5320", "entity_type": "1", "catno": "SKL 4955", "id": 5320, "name": "Decca"}]...There is more...
How can i for instance get the information from "styles" using PHP so it will output "Blues Rock, Rock & Roll"? Maybe I also want to get info from "description" to output "The Rolling Stones - Beggars Banquet FULL ALBUM (mono vinyl mix)".
Kind regards Johan