Skip to content

podcasthosting/podcast-client-spotify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Install

Via Composer

$ composer require podcasthosting/podcast-client-spotify

Intro

Create (add), get status, update url and remove (delete) podcasts on Spotify (DeliveryClient).

You can also fetch analytics data from a different Spotify API (AnalyticsClient).

You´ll need to be a certified podcast provider (aggregator) to use these APIs.

Documentation

DeliveryClient

$auth = new AuthClient($clientId, $clientSecret);
$token = $auth->getToken();

// Initiate client
$client = new Delivery\Client($token->access_token);

// Create podcast entry on Spotify
try {
    $res = $client->create('Example Feed', 'https://example.podcaster.de/feed.rss');
    if ($res instanceof Delivery\Result) {
        // Do something with SpotifyUri
        $spotifyUri = $res->getSpotifyUri(); // Result e.g. spotify:show:123
    }
} catch (AuthException $e) {
} catch (DomainException $e) {
} catch (DuplicateException $e) {
}

// Get status and info for podcast entry on Spotify
try {
    $res = $client->status($spotifyUri);
    if ($res instanceof Result) {
        // A description of the current status of the podcast.
        $statusDescription = $res->getStatusDescription();
        // A list of descriptive validation errors for the podcast
        $validationErrors = $res->getValidationErrors();
    }
} catch (AuthException $e) {
} catch (DomainException $e) {
} catch (NotFoundException $e) {
}

// Update uri for podcast entry on Spotify
try {
    $newUrl = 'https://example.podcaster.de/newfeed.rss';
    $res = $client->status($spotifyUri, $newUrl);
    if (true === $res) {
      // Is updated
    }
} catch (AuthException $e) {
} catch (DomainException $e) {
} catch (NotFoundException $e) {
}

// Remove podcast entry
try {
    $res = $client->remove($spotifyUri);
    if (true === $res) {
      // Is removed
    }    
} catch (AuthException $e) {
} catch (DomainException $e) {
} catch (NotFoundException $e) {
}

AnalyticsClient

$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) {
}

Testing

Not yet available. Sorry.

$ composer test

Contributing

You´ll find the source on Github. Feel free to submit patches.

License

The MIT License (MIT). Please see License File for more information.

About

Create, get status, update and remove podcasts on Spotify. Fetch analytics data.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages