开发者

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

I'm writing a music reference app and for each album (pulled from last.fm) would like to link to the ITMS (if the album is in the store).

iTunes link maker web tool http://apple.com/itunes/linkmaker/ is great for getting links for a known album but I need to access it programatically from within my app.

This NSLog blogpost which is from 2003 but was referenced more recently in another question here seems to offer the only solution I've come across so far, suggesting to submit a query to:

phobos.apple.com/WebObjects/MZSearch.woa/wa/advancedSearchResults?

Put "itms://" before it and the link will work in iTunes, put "http://" before it and the link will work in Camino (Safari sometimes spits back a malformed XML error).

The tags that are of importance are as follows:

  • songTerm - song title
  • artistTerm - artist name
  • albumTerm - album name
  • composerTerm - composer name
  • term - all fields

The suggestion is that would using http:// rather than itms:// the server will return an XML document of results instead of opening iTunes but either way I am sent directly to iTunes.

Is it possible to g开发者_高级运维et back a list of results?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜