day4/blubrry-sdk

Client SDK for Blubrry API version 2

2.0.0 2020-10-12 17:49 UTC

This package is not auto-updated.

Last update: 2024-12-18 12:04:29 UTC


README

The SDK is based on Blubrry API version 2 and you can find the documentation here

Supported Features

  • Media Hosting
  • Podcast Statistics
  • Social Medias

Installation

Blubrry SDK requires PHP v7.2+ to run.

use Blubrry\REST\Api

Authenticating Users

The Blubrry API has OAuth2.0 authentication system.

In way to keep using that authentication system, you will have to implement some thing to make that work. The first step is to contat the Blubrry Support Team and ask them for user credentials to use their API.

After that, you will have to add a button into your Website with a redirect to a link like this:

https://api.blubrry.com/oauth2/authorize?response_type=code&client_id=$client_id&redirect_uri=$redirect_uri

Where:

This will return a link like this:

https://$redirect_uri/code=767a88a9576asdasdasda123123cfd

Then, you will have to retrieve a Refresh token for this user:

- getRefresh

Description: Gets Access and Refresh token from Blubrry API.

Example request:

<?php

$api = new \Blubrry\REST\API();

$code = '767a88a9576asdasdasda123123cfd';
$redirectUri = 'https://google.com/login';
$clientId = '123456789';
$clientSecret = '12d3sa4d56as74d65asd32as1d';

$api->auth($clientId, $clientSecret)->getRefresh($code, $redirectUri);

Example response:

{"access_token":"3b636a92ee50a8f17543f6a531b27e55d525bcd1", "expires_in":3600, "token_type":"bearer", "scope":null, "refresh_token":"55b01e60a74e45b3c66032627dcbc0dddd0bbd6a"}

And then, you will use the access_token to be able to do requests to the another API endpoits.

The access_token expires in one hour, you will need to save the refresh_token locally and send a request to the endpoint refreshToken to retrieve a new access_token without need of the user loggin into the Blubrry account.

- getNewAccessToken

Description: Updates the Access token using the Refresh Token.

Example request:

<?php

$api = new \Blubrry\REST\API();

$clientId = '123456789';
$clientSecret = '12d3sa4d56as74d65asd32as1d';
$refreshToken = '55b01e60a74e45b3c66032627dcbc0dddd0bbd6a';

$api->auth($clientId, $clientSecret)->getNewAccessToken($refreshToken);

Example response:

{"access_token":"3b636a92ee50a8f17543f6a531b27e55d525bcd1", "expires_in":3600, "token_type":"bearer", "scope":null}

Endpoints

- listPrograms

Description: List Programs from Blubrry.

Example request:

<?php

$api = new \Blubrry\REST\API($accessToken);

$start = 0;
$limit = 100;

$api->mediaHosting()->listPrograms($limit, $start);

Example response:

[
  {
    "program_id":"1",
    "program_title":"Your Program Title",
    "program_keyword":"somewordhere"
  }
]

- listUnpublished

Description: List umpublished Media from Blubrry.

Example request:

<?php

$api = new \Blubrry\REST\API($accessToken);

$start = 0;
$limit = 100;
$programKeyword = "my_program";

$api->mediaHosting()->listUnpublished($programKeyword, $limit, $start);

Example response:

{}

- publishMedia

Description: Publish Media into Blubrry.

Example request:

<?php

$api = new \Blubrry\REST\API($accessToken);

$programKeyword = "my_program";
$mediafile = "";
$publish = false;

$api->mediaHosting()->publishMedia($programKeyword, $mediafile, $publish);

Example response:

{}

- deleteMedia

Description: Delete media from Blubrry

Example request:

<?php

$api = new \Blubrry\REST\API($accessToken);

$programKeyword = "my_program";
$mediafile = "";

$api->mediaHosting()->deleteMedia($programKeyword, $mediafile);

Example response:

{}

- addMigrateMediaUrl

Description: Adds media URLs to the migration queue.

Example request:

<?php

$api = new \Blubrry\REST\API($accessToken);

$programKeyword = 'my_program';
$url = '';
$urls = ['', ''];

$api->mediaHosting()->addMigrateMediaUrl($programKeyword, $url, $urls);

Example response:

{"success":"URL(s) added successfully."}

- removeMigrateMediaUrl

Description: Remove media URLs from the migration queue.

Example request:

<?php

$api = new \Blubrry\REST\API($accessToken);

$programKeyword = 'my_program';
$url = '';
$urls = ['', ''];
$ids = [123, 321, 3444, 3555];

$api->mediaHosting()->removeMigrateMediaUrl($programKeyword, $url, $urls, $ids);

Example response:

{"success":"URL removed successfully."}

- migrateStatus

Description: Makes the uploaded media file publicly available.

Example request:

<?php

$api = new \Blubrry\REST\API($accessToken);

$programKeyword = 'my_program';
$status = 'queued';
$start = 0;
$limit = 100;
$ids = [123, 321, 3444, 3555];

$api->mediaHosting()->migrateStatus($programKeyword, $status, $start, $limit, $ids);

Example response:

{}

- uploadMedia

Description: Uploads a media file to the server.

Example request:

<?php

$api = new \Blubrry\REST\API($accessToken);

$programKeyword = 'my_program';
$media_file = '';

$api->mediaHosting()->uploadMedia($programKeyword, $media_file);

Example response:

{}

- summary

Description: Gets Podcast Summary.

Example request:

<?php

$api = new \Blubrry\REST\API($accessToken);

$programKeyword = 'my_program';
$media_file = '';

$api->podcastStatistics()->summary($programKeyword, $month, $year);

Example response:

{
    "stats_url":"http:\/\/stats.blubrry.com",
    "program_id":"123456",
    "overall": {
        "total":null,
        "unique":null
    },
    "current_month": {
        "total":null,
        "unique":null
    },
    "last_month": {
        "total":null,
        "unique":null
    },
    "media":[]
}

- totals

Description: Get totals from a specific podcast, only available to professional statistics accounts. Note: start-date and end-date range cannot exceed 45 days.

Example request:

<?php

$api = new \Blubrry\REST\API($accessToken);

$programKeyword = 'my_program';
$start_date = '';
$end_date = '';
$fields = '';
$start = '';
$limit = ;

$params = [
    'start-date' => $start_date,
    'end-date'   => $end_date,
    'fields'     => $fields,
    'start'      => $start,
    'limit'      => $limit,
];

$api->podcastStatistics()->totals($programKeyword, $params);

Example response:

{}

- updateListing

Description: Updates the social listing.

Example request:

<?php

$api = new \Blubrry\REST\API($accessToken);

$programKeyword = 'my_program';

$params = [
    'feed-url'  => $feedUrl,
    'title'     => $title,
    'date'      => $date,
    'guid'      => $guid,
    'media-url' => $mediaUrl,
    'subtitle'  => $subtitle,
    'duration'  => $duration,
    'filesize'  => $filesize,
    'explicit'  => $explicit,
    'link'      => $link,
    'image'     => $image,
];

$api->social()->updateListing($programKeyword, $params);

Example response:

{}

- getSocial

Description: Get Social Options.

Example request:

<?php

$api = new \Blubrry\REST\API($accessToken);

$programKeyword = 'my_program';

$params = [
    'twitter' => [
        'podcast-id'   => $podcastId,
        'post-data'    => $postData,
        'social-id'    => $socialId,
        'social-type'  => 'twitter',
        'social-title' => $socialTitle,
        'form-data'    => [
            'row-type'  => 'HTML',
            'row-order' => 1,
            'row-arrtibutes' => [
                'content' => '<p>hi</p>',
            ],
        ],
    ],
    'youtube' => [
        'podcast-id'   => $podcastId,
        'post-data'    => $postData,
        'social-id'    => $socialId,
        'social-type'  => 'youtube',
        'social-title' => $socialTitle,
        'form-data'    => [
            'row-type'  => 'HTML',
            'row-order' => 1,
            'row-arrtibutes' => [
                'content' => '<p>hello</p>',
            ],
        ],
    ],
    'facebook' => [
        'podcast-id'   => $podcastId,
        'post-data'    => $postData,
        'social-id'    => $socialId,
        'social-type'  => 'facebook',
        'social-title' => $socialTitle,
        'form-data'    => [
            'row-type'  => 'HTML',
            'row-order' => 1,
            'row-arrtibutes' => [
                'content' => '<p>hello</p>',
            ],
        ],
    ],
];

$api->social()->getSocial($programKeyword, $params);

Example response:

{}

- postSocial

Description: Post to Social.

Example request:

<?php

$api = new \Blubrry\REST\API($accessToken);

$programKeyword = 'my_program';

$body = [
    'podcast-id'  => $podcastId,
    'post-data'   => $postData,
    'social-id'   => $socialId,
    'social-type' => 'twitter',
    'social-data' => [
        'title-123456' => 'My awesome title for twitter',
    ],
];

$api->social()->postSocial($programKeyword, $body);

Example response:

{}

LICENSE

This SDK is open source with a public repository on GitHub.