diff --git a/.gitignore b/.gitignore index df6decd..0696013 100644 --- a/.gitignore +++ b/.gitignore @@ -161,3 +161,6 @@ pip-log.txt # Mac crap .DS_Store + +# ignore html files in the root, all are generated by VS or subl +/*.html diff --git a/README.md b/README.md index 3677d07..03aed98 100644 --- a/README.md +++ b/README.md @@ -4,28 +4,82 @@ MIT licensed. Maintained by [@rikkilt](http://twitter.com/rikkilt). Feature request? Bug? Or just wanna help out? Check out [the issues on GitHub](https://github.com/inflatablefriends/lastfm/issues). -If you have comments or need some help, just post to our chat room on [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/inflatablefriends/lastfm?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) - -## Quickstart - -```c# -var auth = new Auth("apikey", "apisecret"); -var response = await auth.GetSessionTokenAsync("username", "pass"); - -if (response.Success && auth.HasAuthenticated) { - var albumApi = new AlbumApi(auth); - var visions = await albumApi.GetAlbumInfoAsync("Grimes", "Visions"); -} -``` - -Some documentation is available on the [GitHub wiki](https://github.com/rikkit/lastfm-wp/wiki), but hopefully the source is good enough to document itself! +If you have comments or need some help, post to our chat room on [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/inflatablefriends/lastfm?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) ## Project Goals - Provide complete, and completely tested, bindings for the Last.fm REST API for use on modern .NET platforms. -- Provide functionality beyond mere API bindings, to spread the joy of Last.fm to developers everywhere. +- Provide functionality beyond API bindings, to spread the joy of Last.fm to developers everywhere. - To be the very best, like no-one ever was. +## Quickstart +### Acquiring the SDK + +You can either: + +- clone this repo and build from source, referencing IF.Lastfm.Core in your project (requires a version of Visual Studio that supports portable class libraries - i.e. any version of VS 2012/2013 *except* 2012 Express) +- download and reference the .dlls from the [latest release](https://github.com/inflatablefriends/lastfm/releases) + +A NuGet package is coming soon. + +### Using the SDK + +Once IF.Lastfm.Core is referenced, it's pretty simple to get started. First, sign up for Last.fm API access if you haven't already + +This is how to get album info: + +```c# +var auth = new LastAuth("apikey", "apisecret"); +var albumApi = new AlbumApi(auth); // this is an unauthenticated call to the API +var response = await albumApi.GetAlbumInfoAsync("Grimes", "Visions"); +var visions = response.Content; // visions is a LastAlbum +``` + +For methods that return several items, you can simply iterate over the response + +```c# +var pageResponse = await artistApi.GetTopTracksForArtistAsync("Ben Frost", page: 5, itemsPerPage: 100); + +foreach (var wallOfSound in pageResponse) +{ + // wallOfSound is a LastTrack +} +``` + +Several API methods require user authentication. Once you have your user's Last.fm username and password: + +```c# +var auth = new LastAuth("apikey", "apisecret"); + +// wait for authentication +var response = await auth.GetSessionTokenAsync("username", "pass"); + +if (response.Success && auth.HasAuthenticated) { + var trackApi = new TrackApi(auth); + var loved = await trackApi.LoveTrackAsync("CIRCLONT6A [141.98][Syrobonkus mix]", "Aphex Twin"); +} +``` + +Some documentation is available on the [GitHub wiki](https://github.com/rikkit/lastfm-wp/wiki). You can also check the Windows Phone demo project for some example code. + +Any problems, just ask in [Gitter](https://gitter.im/inflatablefriends/lastfm). + +## Dependency Injection + +The SDK is built to work with IoC libraries like MvvmLight and Ninject. To inject an API as a dependency to a viewmodel, you just need to register ```ILastAuth``` to an instance of ```LastAuth```: + +```c# +// mvvmlight +var auth = new LastAuth("apikey", "apisecret"); +SimpleIoc.Default.Register(() => auth); + +// ... + +var artistApi = ServiceLocator.Current.GetInstance(); +var response = await artistApi.GetArtistInfoAsync("The Knife"); +var theKnife = artist.Content; +``` + ## Implemented Features Check the [progress report](https://github.com/inflatablefriends/lastfm/blob/master/PROGRESS.md) for a list of implemented methods.