PHP code example of podcasthosting / podcast-client-spotify
1. Go to this page and download the library: Download podcasthosting/podcast-client-spotify library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
podcasthosting / podcast-client-spotify example snippets
php
$auth = new AuthClient($clientId, $clientSecret);
$token = $auth->getToken();
// Initiate client
$client = new Analytics\Client($token->access_token, $clientId);
// Fetch analytics data from Spotify
try {
$res = $analyticsClient->get((new \DateTime())->setDate(\DateInterval::createfromdatestring('-1 day')));
if ($res instanceof Analytics\Result) {
// Iterate over JSON objects (from json_decode)
foreach($res->getDecoded() as $jsonObject) {
}
// Iterate over raw JSON strings
foreach($res->getRaw() as $sJson) {
}
}
} catch (AuthException $e) {
}