https://github.com/chrismou/php-discogs-wrapper
A simple Discogs API wrapper for PHP, with Guzzle 6 support
https://github.com/chrismou/php-discogs-wrapper
Last synced: 3 months ago
JSON representation
A simple Discogs API wrapper for PHP, with Guzzle 6 support
- Host: GitHub
- URL: https://github.com/chrismou/php-discogs-wrapper
- Owner: chrismou
- License: mit
- Created: 2016-02-15T14:12:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-24T14:38:32.000Z (about 9 years ago)
- Last Synced: 2025-01-28T02:44:48.277Z (4 months ago)
- Language: PHP
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PHP Discogs API Wrapper
[](https://travis-ci.org/chrismou/php-discogs-wrapper)
[](https://codeclimate.com/github/chrismou/php-discogs-wrapper/coverage)
[](https://codeclimate.com/github/chrismou/php-discogs-wrapper)
[](https://www.paypal.me/chrismou)A simple wrapper class for the discogs API.
#### This is an early days version. I'd probably advise not using it just yet, as methods are liable to change without notice until I'm happy enough with it to tag a version.
## Installation
Once the library is stable, it'll be added to packagist. Until then, you can access it by setting a custom repository in your composer.json.
First, add a reference to the package:
```
"require": {
"chrismou/discogs": "dev-master"
}
```Next, add a custom repository:
```
"repositories": [
{
"type": "vcs",
"name": "chrismou/discogs",
"url": "https://github.com/chrismou/php-discogs-wrapper"
}
]
```Now, running `composer update` should pull in the development package
## Usage
Currently, the library only supports usage based on a pre-acquired Discogs API access token. You can grab an access token by creating an
Discogs account and setting up an application here: [https://www.discogs.com/settings/developers]. Once set up, click the `Generate new token'
button to generate a personal access token.To set up the Discogs API client:
```
$discogs = new \Chrismou\Discogs\Discogs(
new GuzzleHttp\Client(),
YOUR_ACCESS_TOKEN,
'YourApplicationName'
);
```The 3rd parameter (YourApplicationName) should be something that identifies your application, and is sent along with the request as the User-Agent header.
See the [documentation](https://www.discogs.com/developers/#page:home,header:home-general-information) for more details.### Methods
For more information on the API response, check the Discogs documentation: [https://www.discogs.com/developers/#page:database]
If a request for a single item returns no results (Discogs returns a `404`) the client will throw a `\Chrismou\Discogs\Exception\NotFoundException` exception.
#### `$discogs->release($releaseId)`
* **$releaseId** (string) - The Discogs Release ID
#### `$discogs->masterRelease($releaseId)`
* **$masterId** (string) - The Discogs "Master" ID
#### `$discogs->masterReleaseVersions($releaseId)`
* **$masterId** (string) - The Discogs "Master" ID
#### `$discogs->artist($artistId)`
* **$artistId** (string) - The Discogs Artist ID
#### `$discogs->artistReleases($artistId)`
* **$artistId** (string) - The Discogs Artist ID
#### `$discogs->label($labelId)`
* **$labelId** (string) - The Discogs Label ID
#### `$discogs->labelReleases($labelId)`
* **$labelId** (string) - The Discogs Label ID
#### `$discogs->search($params)`
* **$params** (array) - An array of search parameters. A full list is available [here](https://www.discogs.com/developers/#page:database,header:database-search)
## Tests
To run the unit test suite:
```
curl -s https://getcomposer.org/installer | php
php composer.phar install
./vendor/bin/phpunit
```If you use docker, you can also run the test suite against all supported PHP versions:
```
./vendor/bin/dunit
```## License
Released under the MIT License. See [LICENSE](LICENSE.md).