php - Difficulty manipulating iTunes API's JSON return data -
i'm creating music based application, , i'm trying access itunes api return link purchase album, generated dynamically based on album clicked on (which works fine, , generates link correct json data). an example link
what can't head around accessing of 'collectionviewurl' key in json, want set href of link appears after album art selected, scored in; $topalbums[$i]['itunes'] = ....
i've tried using json_decode access data whenever try access key need no return. missing simple this?
==================================
(my current code section)
$itunes_link_prefix = "https://itunes.apple.com/search?country=gb&media=music&entity=album&limit=1&artist="; ($i = 0; $i < 6; $i++) { $topalbum[$i]['title'] = $xml['top_albums']->topalbums->album[$i]->name; $topalbum[$i]['image'] = $xml['top_albums']->topalbums->album[$i]->image[3]; $json_link = $itunes_link_prefix . $artist . "&term=" . urlencode($topalbum[$i]['title']); $topalbum[$i]['itunes'] = (contents of collectionviewurl key) }
for this, remember json has transformed "before" can operate it. see in example show have somehting json content (with curl or don't know how do), content do:
$itunesdisc = json_decode($jsonfromitunes); then, have contents of json. if json's itunes returns in form of response:[...] can simplicity
$itunesdisc = $itunesdisc["response"]; then can walk through array. maybe page can in show content of json response http://jsonviewer.stack.hu/
Comments
Post a Comment