gabrieljmj / deezer-web-api
Deezer Web API with PHP
v0.1.3
2015-09-12 13:39 UTC
Requires
- php: >=5.4.0
- guzzlehttp/guzzle: ^6.0
Requires (Dev)
- phpunit/phpunit: 4.8.*
This package is auto-updated.
Last update: 2025-01-16 04:37:49 UTC
README
Deezer Web API with PHP.
Install
Via Composer:
$ composer require gabrieljmj/deezer-web-api
Usage
Authentication
use DeezerWebApi\DeezerSession; use DeezerWebApi\DeezerWebApi; session_start(); $session = new DeezerSession(getenv('DEEZER_APP_ID'), getenv('DEEZER_APP_SECRET'), getenv('DEEZER_REDIRECT_URI')); if (empty($_GET['code'])) { $state = md5(uniqid(rand(), true)); $session->setState($state); $_SESSION['state'] = $state; $perms = ['manage_library']; header('Location: ' . $session->getAuthUri($perms); } $code = $_GET['code']; $accessToken = $session->getAccessToken($code); $deezer = new DeezerWebApi(); $deezer->setAccessToken($accessToken); // Or new DeezerWebApi(null, $accessToken); $me = $deezer->get('user/me');
Methods
get($resource[, array $params = []])
$me = $deezer->get('user/me');
post($resource[, array $params = []])
$response = $deezer->post('user/me/playlists', ['title' => 'PLAYLIST_TITLE']);