iTunes Music Store Link Maker — how to search from within my app?

五迷三道 提交于 2019-12-02 18:55:54
thierryb

I am using LinkMaker to get iTunes details about song I am playing. For that, I found that LinkMaker is able to return json data and also 1 result at a time.

I am using this url to perfom my query :

http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStoreServices.woa/wa/itmsSearch?lang=1&output=json&country=%@&term=%@&media=%@&limit=1"

Here are parameters you need to give :

> country : store country term : could
> contains artist name, song name, album
> media : music

For exemple, if you want to have details for a song called "One" by "U2" here is the correct URL :

http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStoreServices.woa/wa/itmsSearch?lang=1&output=json&country=US&term=U2%20one&media=music&limit=1

Then you will receive json data like this :

{
 "resultCount":1,
 "results": [
{"wrapperType":"track", "mediaType":"song", "artistName":"U2", "itemParentName":"Achtung Baby", "itemParentCensoredName":"Achtung Baby", "itemCensoredName":"One", "itemName":"One", "artistLinkUrl":"http://itunes.apple.com/us/artist/u2/id78500?uo=4", "artworkUrl60":"http://a1.phobos.apple.com/us/r1000/009/Features/32/9a/60/dj.mfynlttx.60x60-50.jpg", "artworkUrl100":"http://a1.phobos.apple.com/us/r1000/009/Features/32/9a/60/dj.mfynlttx.100x100-75.jpg", "country":"USA", "currency":"USD", "discCount":1, "discNumber":1, "itemExplicitness":"notExplicit", "itemLinkUrl":"http://itunes.apple.com/us/album/one/id368713?i=368617&uo=4", "itemPrice":"1.29000", "itemParentExplicitness":"notExplicit", "itemParentLinkUrl":"http://itunes.apple.com/us/album/one/id368713?i=368617&uo=4", "itemParentPrice":"9.99000", "previewUrl":"http://a1.phobos.apple.com/us/r1000/019/Music/b6/8c/c5/mzm.epegonxg.aac.p.m4a", "primaryGenreName":"Rock", "trackCount":12, "trackNumber":3, "trackTime":276042}]
}

You need then to decode these JSON data.

NSDictionary *jsonResultsParsed = [jsonResults JSONValue];

And finally get what you want :

NSDictionary *songDetailsDict = [[jsonResultsParsed objectForKey:@"results"] objectAtIndex:0];

If you want to determine user's country you will need to determine its country using its locale, here is the code I am using :

- (NSString *)getUserCountry
{
    NSLocale *locale = [NSLocale currentLocale];
    return [locale objectForKey: NSLocaleCountryCode];
}

Hope this helps.

Thierry

Edit: Finally a doc is available:

http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html

This document for iTunes Store Web Service Search API (pdf), although old and incomplete, seems to be the way to accomplish this.

It's a painful experience setting this up though, as has been every other part of the affiliate programme.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!