marcel-strahl / spotify-web-api-client
An http client for interaction with the Spotify api written in php
Requires
- php: ^8.0|^8.1
- ext-curl: *
- ext-json: *
- ext-simplexml: *
- guzzlehttp/guzzle: ^7.4
- guzzlehttp/psr7: ^2.1
- laminas/laminas-diactoros: ^2.8
- psr/http-message: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.6
- phpstan/phpstan: ^1.4
- phpstan/phpstan-phpunit: ^1.0
- phpstan/phpstan-webmozart-assert: ^1.0
- phpunit/phpunit: ^9.5
- psalm/plugin-phpunit: ^0.16.1
- roave/security-advisories: dev-latest
- vimeo/psalm: ^4.20
This package is auto-updated.
Last update: 2024-11-27 02:17:26 UTC
README
Important note
This package is currently in development of the alpha version and provides only the simple backend login (Client Credentials Flow: https://developer.spotify.com/documentation/general/guides/authorization/client-credentials/) and the fetching of a track via Track-ID.
Outlook of the next steps
In the future, we want to provide authentication across all 3 authorizations, as well as a client that can communicate with all endpoints of Spotify's web app.
Usage:
<?php declare(strict_types=1); use Laminas\Diactoros\RequestFactory; use MarcelStrahl\SpotifyWebApiClient\Client\WebApiClient; use MarcelStrahl\SpotifyWebApiClient\Facade\SpotifyQrClientFacade; use MarcelStrahl\SpotifyWebApiClient\Facade\WebApiAuthFacade; use MarcelStrahl\SpotifyWebApiClient\Facade\WebApiClientFacade; use MarcelStrahl\SpotifyWebApiClient\Model\Credentials; use MarcelStrahl\SpotifyWebApiClient\Model\SpotifyQrClient\QrCodePreference; use Webmozart\Assert\Assert; require __DIR__ . '/../vendor/autoload.php'; $requestFactory = new RequestFactory(); $facade = new WebApiAuthFacade($requestFactory); $authenticationClient = $facade->buildInstance(); $accessToken = $authenticationClient->loadAccessToken(Credentials::create([ 'clientId' => '', 'clientSecret' => '', ])); $apiFacade = new WebApiClientFacade($requestFactory); $webApiClient = $apiFacade->buildInstance($accessToken); Assert::isInstanceOf($webApiClient, WebApiClient::class); $track = $webApiClient->getTrackById('4xkOaSrkexMciUUogZKVTS'); $qrClientFacade = new SpotifyQrClientFacade($requestFactory); $qrClient = $qrClientFacade->buildInstance(); $qrClient->fetchQrCode(QrCodePreference::create( '000000', QrCodePreference::BAR_COLOR_WHITE, 640, QrCodePreference::FORMAT_JPEG, $track->getUri(), )); var_dump($track, $file);
Contribute
This library is under active development. If you encounter bugs, have suggestions for improvements or enhancements, or want to implement, you can open an issue.
If you want to work on the documentation or on a reported bug or suggested feature, you can do so by forking the project and later submitting a pull request on Github. If you need help at any time, don't hesitate to ask for assistance.