Saturday, May 25, 2013

7digital on Mobile

Linking to 7digital on mobile devices

You may have noticed that all 7digital API responses automatically include affiliated "buy" links to our main 7digital.com site. But what if you're building a mobile app? Here's a quick guide on how to link to 7digital on mobile devices:



Your 7digital Partner ID

Before starting you'll need to know your 7digital partner ID. By providing your partner ID we know that you play nice and follow our guidelines about linking to us and also allows you to earn commission from any sales driven by your app.

If you don't know your partner ID, the easiest way to find it out is by making any API request using your 7digital API key, eg.:
http://api.7digital.com/1.2/artist/details?artistid=1&oauth_consumer_key=YOUR_KEY_HERE
and look for ?partner=XXXX in the buy links (<url>) generated for you in the response, e.g.:

<url>http://www.7digital.com/artists/keane/?partner=1234</url>
means your 7digital partner ID is 1234.

 

 

Once you know your partner ID you can choose one from one of the options below:



7digital Mobile web store<

7digital Mobile Web Store

The 7digital mobile web store allows mobile users to browse, preview, purchase and listen to full versions of tracks without the need for an application.

  • HTML5 compatible - works on iPhone / iPad
  • Access previously purchased tracks using 7digital's cloud-based Locker
  • Buy and play new music on the go

To create deep links to our mobile store your URLs should follow the below templates:

Artists:

http://m.7digital.com/{countryCode}/artists/{artistId}?partner={partnerId}

e.g. http://m.7digital.com/GB/artists/304?partner=1234

Releases:

http://m.7digital.com/{countryCode}/releases/{releaseId}?partner={partnerId} e.g. http://m.7digital.com/US/releases/975?partner=1234

Tracks: for a track purchase link please link to the release the track appears on (see URL template above)

 

Search:

http://m.7digital.com/{countryCode}/search?q={search query}&partner={partnerId} e.g. http://m.7digital.com/ES/search?q=radiohead&partner=1234

artistId, releaseId and countryCode are standard 7digital IDs as used through out the 7digital API
partnerId is your 7digital partner ID as described above



Non-country specific links

If you don't know in which country is the user located, you should omit the country code and a local shop will be picked for the user automatically, e.g. intsead of
http://m.7digital.com/ES/search?q=radiohead&partner=1234 you can use:
http://m.7digital.com/search?q=radiohead&partner=1234



7digital Mobile - Android

7digital for Android

The 7digital Music app for Android now includes both the player and music store. Discover, buy and listen to music anywhere. Sync and play music you have previously purchased.

  • Access – Discover, buy and listen to music anywhere
  • music store with full 7digital catalogue
  • Sync your 7digital music from the cloud to your phone wirelessly
  • 30 second previews of all songs
  • Last.fm scrobbling
  • Integrated music player
  • Play music that is already stored on your device
  • Browse Top album and track charts, new releases and genres
  • Quality 320kbps MP3s/AACs
  • Compatibility with Android 2.1 and above

Download the 7digital Android app directly to your phone from the Android Market.


The 7digital Android App supports following intents:

 

VIEW_ARTIST - opens artist screen Intent i = new Intent();
i.setClassName("uk.co.sevendigital.android", "uk.co.sevendigital.android.library.shop.SDIExternalActionActivity");
i.setAction("uk.co.sevendigital.android.intent.action.VIEW_ARTIST");
i.putExtra("uk.co.sevendigital.android.intent.extra.PARTNER", partnerId);
i.putExtra("ARTISTID",artistId);
startActivity(i);
partnerId is your 7digital partner ID as described above
artistId is the 7digital artist ID

 

VIEW_RELEASE - opens release screen (with optional track highlighting) Intent i = new Intent();
i.setClassName("uk.co.sevendigital.android", "uk.co.sevendigital.android.library.shop.SDIExternalActionActivity");
i.setAction("uk.co.sevendigital.android.intent.action.VIEW_RELEASE");
i.putExtra("uk.co.sevendigital.android.intent.extra.PARTNER", partnerId);
i.putExtra("RELEASEID",releaseId);
i.putExtra("TRACKID",trackId);
startActivity(i);
partnerId is your 7digital partner ID as described above
releaseId is the 7digital release ID
trackId optional parameter - if provided the selected track is highlighted on the release screen

 

SEARCH - opens search results screen Intent i = new Intent("uk.co.sevendigital.android.intent.action.SEARCH");
i.putExtra(SearchManager.QUERY, searchQuery);
i.putExtra("uk.co.sevendigital.android.intent.extra.PARTNER", partnerId);
startActivity(i);
partnerId is your 7digital partner ID as described above
searchQuery is the query string that's being searched for

 

For every intent you will need to catch an exception for the case where the 7digital application is not installed.

Here's an example how you can handle this by replacing startActivity with your own custom start7digitalActivity:

/**
 *  Start the 7digital application. On failure, go to the Google Play if it is installed.
 * @param i The Intent used to start the Activity
 */ 
protected void start7digitalActivity(Intent i) {
	try {
		startActivity(i);
	} catch (ActivityNotFoundException e) {
		Toast.makeText(this, 
			R.string.the_7digital_not_installed_please_install_it_from_google_play_, 
				Toast.LENGTH_LONG).show();
		// Take user to market
		String marketQuery = "market://details?id=uk.co.sevendigital.android";
		Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse(marketQuery));
		try {
			startActivity(intent);
		} catch (ActivityNotFoundException e1) {
			Toast.makeText(this, 
				R.string.google_play_not_found_please_install_the_7digital_app_manually_, 
					Toast.LENGTH_LONG).show();
		}
	}		
} 

Downloads for 7digital on Mobile

Click on the links below to download the attachments
Android Example Project [11 KB]