PHP code example of day4 / blubrry-sdk

1. Go to this page and download the library: Download day4/blubrry-sdk 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/ */

    

day4 / blubrry-sdk example snippets

 php


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

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

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


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

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

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


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

$start = 0;
$limit = 100;

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


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

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

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


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

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

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


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

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

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


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

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

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


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

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

$api->mediaHosting()->removeMigrateMediaUrl($programKeyword, $url, $urls, $ids);
 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);
 php


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

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

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


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

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

$api->podcastStatistics()->summary($programKeyword, $month, $year);
 json
{
    "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":[]
}
 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);
 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);
 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);