1. Go to this page and download the library: Download joeyboli/radioapisdk 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/ */
joeyboli / radioapisdk example snippets
use RadioAPI\RadioAPI;
// Set up your client
$api = RadioAPI::make('https://api.radioapi.io', 'your-api-key')
->service(RadioAPI::SPOTIFY)
->withHistory();
// Find out what's playing on a stream
$stream = $api->getStreamTitle('https://stream.example.com/radio');
if ($stream->isSuccess()) {
$track = $stream->getCurrentTrack();
echo "Now playing: {$track['artist']} - {$track['song']}\n";
foreach ($stream->getHistory() as $historical) {
echo "Previously: {$historical['artist']} - {$historical['song']}\n";
}
}
use RadioAPI\RadioAPI;
// Simple instantiation
$api = new RadioAPI('https://api.radioapi.io', 'your-api-key');
// Or using the fluent factory
$api = RadioAPI::make('https://api.radioapi.io', 'your-api-key')
->language('en') // Response language (ISO 639-1)
->service(RadioAPI::AUTO) // Default service/platform
->withHistory() // Include track history by default
->timeout(60); // Request timeout in seconds
// Fetch current metadata
$stream = $api->getMetadata($uuid, ['locale' => 'fr']);
// Fetch track history
$history = $api->getMetadataHistory($uuid, ['limit' => 20]);
// Fetch most played tracks
$popular = $api->getMetadataPopular($uuid, ['limit' => 10]);
// General stats for all your endpoints
$globalStats = $api->getMetadataStats(['days' => 30]);
// Detailed stats for a specific endpoint
$stats = $api->getMetadataEndpointStats($uuid, ['days' => 7]);
echo "Total Requests: " . $stats->getTotalRequests();
print_r($stats->getRequestsByDay());
$endpoint = $api->createMetadataEndpoint('jcplayer', '...');
// Update the endpoint
$endpoint->update(['history' => false]);
// Get live metadata
$metadata = $endpoint->getMetadata();
// Get history or popular tracks
$history = $endpoint->getHistory();
$popular = $endpoint->getPopular();
// Get its specific stats
$stats = $endpoint->getStats();
// Or delete it
$endpoint->delete();