-
Notifications
You must be signed in to change notification settings - Fork 11
#Old E.Deezer
Note: This only applies to 1.X.X.X version of E.Deezer. Current Version.
Note: Since 1.X.X.X versions of E.Deezer have been deprecated please use a 2.X.X.X version of E.Deezer.
##Getting Started
The easiest way to get started is download our Nuget Package
All functions are provided with these 2 namespaces:
E.Deezer //Base connection objects
E.Deezer.Api //Deezer API objects
To start accessing the Deezer API you'll need to create a DeezerSession object. Once created you'll need to a DeezerClient with the newly created session. You can use the Deezer API with the Client. The following snippet shows how to create a Client.
Note The DeezerSession will handle OAuth requests for the application. This has not been implemented yet so although the parameters are required they are currently not used.
//A username to use with Deezer
//NOTE: Not currently used. Can be set to string.Empty
string USERNAME = [USERNAME];
//Your application ID on developers.deezer.com
//NOTE: Not currently used. Can be set to string.Empty
string APPLICATIONID = [APP ID];
//Your application secret on developers.deezer.com
//NOTE: Not currently used. Can be set to string.Empty
string APPLICATIONSECRET = [APP SECRET];
//Requested application permissions
//Can except multiple (DeezerPermissions.Email | DeezerPermissions.History)
//DeezerPermissions.OfflineAccess is equivalent to all permissions
//See permissions section of developers.deezer.com
DeezerPermissions PERMISSIONS = DeezerPermissions.Email;
//Create a session with this information
DeezerSession Session = new DeezerSession(USERNAME, APPLICATIONID, APPLICATIONSECRET, PERMISSIONS);
//Use this session to create a DeezerClient
//Use this to access the Deezer API!
DeezerClient Client = new DeezerClient(session);
Most methods in E.Deezer return a Book of the requested type. A book contains the total number of items in the Deezer library that matches the method you called.
To get data from the book you have to read it, by using the read()
method. This method accepts 2 params:
- aStart -> Where you wish to start in the book
- aCount -> The number of items you wish, starting at aStart
The callback function is passed a Page which contains a list of the data requested and a reference to where the starting point is.
The example below shows how to obtain data from a search:
//Assuming you have setup your DeezerClient
//If not, see "Getting Started"
//Perform the search
var result = Client.SearchAlbums("Abba");
//Wait for the task
try { result.Wait(); }
//Make sure to catch any exceptions that occur
//An exception may be thrown if the request fails
//or there is no active internet connection.
catch(AggregateException ex) { Console.WriteLine(ex.GetBaseException().Message); }
//We have the Data - print the total number of results
var book = result.Result;
Console.WriteLine(book.Total);
//Read the book to get the first 25 items
var readTask = book.Read(0, 25);
//Our readTask.Result should contain the 25 items requested
//Remember to catch any exceptions (like above)
var items = readTask.Result.Data;