PHP code example of listennotes / podcast-api

1. Go to this page and download the library: Download listennotes/podcast-api 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/ */

    

listennotes / podcast-api example snippets





lerplate to make an api call
try {

    define( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

    $objClient = new ListenNotes\PodcastApi\Client( API_KEY );
    $strResponse = $objClient->typeahead( [ 'q' => 'startup', 'show_podcasts' => '1' ] );
    $arrHeaders = $objClient->getHeaders();

    print("\n=== Some account info ===\n");
    printf( "Free Quota this month: %s requests\n" , $arrHeaders['x-listenapi-freequota'] );
    printf( "Usage this month: %s requests\n" , $arrHeaders["x-listenapi-usage"] );
    printf( "Next billing date: %s\n" , $arrHeaders["x-listenapi-nextbillingdate"] );

    print("\n=== Response data ===\n");
    print_r( json_decode( $strResponse ) );
    
} catch ( ListenNotes\PodcastApi\Exception\APIConnectionException $objException ) {
    print("Failed ot connect to Listen API servers");
} catch ( ListenNotes\PodcastApi\Exception\AuthenticationException $objException ) {
    print("Wrong api key, or your account has been suspended!");
} catch ( ListenNotes\PodcastApi\Exception\InvalidRequestException $objException ) {
    print("Wrong parameters!");
} catch ( ListenNotes\PodcastApi\Exception\NotFoundException $objException ) {
    print("Endpoint not exist or the podcast / episode not exist!");
} catch ( ListenNotes\PodcastApi\Exception\RateLimitException $objException ) {
    print("You have reached your quota limit or rate limit!");
} catch ( ListenNotes\PodcastApi\Exception\ListenApiException $objException ) {
    print("Something wrong on Listen Notes servers");
} catch ( Exception $e ) {
    print("Other errors that may not be related to Listen API");
}





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->search( [ 'q' => 'startup' ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->typeahead( [ 'q' => 'startup', 'show_podcasts' => '1' ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->getPodcastById( [ 'id' => '4d3fe717742d4963a85562e9f84d8c79' ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->fetchEpisodeById( [ 'id' => '6b6d65930c5a4f71b254465871fed370',
    'show_transcript' => '1' ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->fetchPodcastLanguages();
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->fetchPodcastGenres( [ 'top_level_only' => '1' ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->fetchBestPodcasts( [ 'genre_id' => '93', 'page' => '2' ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->fetchPodcastRegions();
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->fetchRecommendationsForPodcast( 
    [ 'id' => '25212ac3c53240a880dd5032e547047b', 'safe_mode' => 1 ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->fetchRecommendationsForEpisode( 
    [ 'id' => '914a9deafa5340eeaa2859c77f275799', 'safe_mode' => 1 ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->batchFetchEpisodes( [ 
    'ids' => 'c577d55b2b2b483c969fae3ceb58e362,0f34a9099579490993eec9e8c8cebb82' ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->batchFetchPodcasts( [ 
    'ids' => '3302bc71139541baa46ecb27dbf6071a,68faf62be97149c280ebcc25178aa731,9cf19c590ff0484d97b18b329fed0c6a' ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->justListen();
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->fetchCuratedPodcastsListById( [ 'id' => 'SDFKduyJ47r' ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->fetchCuratedPodcastsLists( [ 'page' => 2 ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->submitPodcast( [ 'rss' => 'https://feeds.megaphone.fm/committed' ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->deletePodcast( [ 'id' => '4d3fe717742d4963a85562e9f84d8c79' ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->fetchPlaylistById( [ 'id' => 'm1pe7z60bsw', 'type' ='podcast_list' ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->fetchMyPlaylists( [ 'page' => '1', 'sort' ='name_a_to_z' ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->fetchTrendingSearches();
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->fetchRelatedSearches( [ 'q' => 'evergrande' ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->spellcheck( [ 'q' => 'evergrand stok' ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->fetchAudienceForPodcast( 
    [ 'id' => '25212ac3c53240a880dd5032e547047b' ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->fetchPodcastsByDomain( 
    [ 'domain_name' => 'nytimes.com' ] );
print_r( json_decode( $strResponse ) );





( 'API_KEY', ( getenv( 'API_KEY' ) ? getenv( 'API_KEY' ) : null ) );

$objClient = new ListenNotes\PodcastApi\Client( API_KEY );

$strResponse = $objClient->searchEpisodeTitles( [ 'q' => 'Jerusalem Demsas on The Dispossessed' ] );
print_r( json_decode( $strResponse ) );

sh