Skip to content

Commit

Permalink
Improved documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Jan 27, 2018
1 parent 4387c81 commit c7ce6f2
Showing 1 changed file with 34 additions and 23 deletions.
57 changes: 34 additions & 23 deletions README.md
@@ -1,20 +1,26 @@
What is the LastFM PHP library?
===============================
Last.fm PHP library
===================
[![Latest Stable Version](https://poser.pugx.org/core23/lastfm-api/v/stable)](https://packagist.org/packages/core23/lastfm-api)
[![Latest Unstable Version](https://poser.pugx.org/core23/lastfm-api/v/unstable)](https://packagist.org/packages/core23/lastfm-api)
[![License](https://poser.pugx.org/core23/lastfm-api/license)](https://packagist.org/packages/core23/lastfm-api)
[![License](https://poser.pugx.org/core23/lastfm-api/license)](LICENSE.md)

[![Total Downloads](https://poser.pugx.org/core23/lastfm-api/downloads)](https://packagist.org/packages/core23/lastfm-api)
[![Monthly Downloads](https://poser.pugx.org/core23/lastfm-api/d/monthly)](https://packagist.org/packages/core23/lastfm-api)
[![Daily Downloads](https://poser.pugx.org/core23/lastfm-api/d/daily)](https://packagist.org/packages/core23/lastfm-api)

[![Build Status](https://travis-ci.org/core23/lastfm-php-api.svg)](http://travis-ci.org/core23/lastfm-php-api)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/core23/lastfm-php-api/badges/quality-score.png)](https://scrutinizer-ci.com/g/core23/lastfm-php-api/)
[![Code Climate](https://codeclimate.com/github/core23/lastfm-php-api/badges/gpa.svg)](https://codeclimate.com/github/core23/lastfm-php-api)
[![Coverage Status](https://coveralls.io/repos/core23/lastfm-php-api/badge.svg)](https://coveralls.io/r/core23/lastfm-php-api)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/582dff80-204e-4edb-a719-58cede02a0c5/mini.png)](https://insight.sensiolabs.com/projects/582dff80-204e-4edb-a719-58cede02a0c5)

[![Donate to this project using Flattr](https://img.shields.io/badge/flattr-donate-yellow.svg)](https://flattr.com/profile/core23)
[![Donate to this project using PayPal](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://paypal.me/gripp)

This library provides a wrapper for using the [Last.fm API] inside PHP.

### Installation
## Installation

Open a command console, enter your project directory and execute the following command to download the latest stable version of this library:

```
composer require core23/lastfm-api
Expand All @@ -23,27 +29,28 @@ composer require guzzlehttp/guzzle # if you want to use Guzzle native
composer require php-http/guzzle6-adapter # if you want to use HTTPlug with Guzzle
```

### Usage
## Usage

```php
// Get HTTPlug client and message factory
$client = \Http\Discovery\HttpClientDiscovery::find();
$messageFactory = \Http\Discovery\MessageFactoryDiscovery::find();

// Create connection
$connection = new \Core23\LastFm\Connection\HTTPlugConnection($client, $messageFactory);
// Auth user to get a token
// http://www.last.fm/api/auth/?api_key=API_KEY
// Create a session (with generated token)
$authApi = new \Core23\LastFm\Service\AuthService($connection);
$session = $authApi->createSession($token);
$chartApi = new \Core23\LastFm\Service\ChartService($connection);
$tags = $chartApi->getTopTags(10);
// Get HTTPlug client and message factory
$client = \Http\Discovery\HttpClientDiscovery::find();
$messageFactory = \Http\Discovery\MessageFactoryDiscovery::find();

// Create connection
$connection = new \Core23\LastFm\Connection\HTTPlugConnection($client, $messageFactory);

// Auth user to get a token
// http://www.last.fm/api/auth/?api_key=API_KEY

// Create a session (with generated token)
$authApi = new \Core23\LastFm\Service\AuthService($connection);
$session = $authApi->createSession($token);

$chartApi = new \Core23\LastFm\Service\ChartService($connection);
$tags = $chartApi->getTopTags(10);
```

### Limitations
## Limitations

Last.fm removed some of their favorite APIs due their relaunch in March 2016. Some of the following removed methods are available via a webcrawler. Please have a look at the `Core23\LastFm\Crawler` package.

Expand Down Expand Up @@ -141,4 +148,8 @@ Last.fm removed some of their favorite APIs due their relaunch in March 2016. So
```

## License

This library is under the [MIT license](LICENSE.md).

[Last.fm API]: http://www.last.fm/api

0 comments on commit c7ce6f2

Please sign in to comment.