PHP code example of fightbulc / cirrus

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

    

fightbulc / cirrus example snippets


// print the username
echo $userVo->getUsername();

// or lets get all tracks from the user
// and then the title from the first track
$tracksVo = $userVo->getTracksVo();
echo $tracksVo[0]->getTitle();



$clientId = '[YOUR API KEY]';
$userId = 428623;

$userVo = \Cirrus\Users\UsersCirrus::init()
  ->setClientId($clientId)
  ->setId($userId)
  ->fetchData();

var_dump($userVo);

// user's full name
echo $userVo->getFullName();

// or get all data for this user as an array
var_dump($userVo->getData());



$clientId = '[YOUR API KEY]';
$userId = 428623;

$userVo = \Cirrus\Users\UsersCirrus::init()
  ->setClientId($clientId)
  ->setId($userId)
  ->withTracksData(TRUE)
  ->withPlaylistsData(TRUE)
  ->withFollowersData(TRUE)
  ->withFollowingsData(TRUE)
  ->withFavoritesData(TRUE)
  ->withWebProfilesData(TRUE)
  ->fetchData();

var_dump($userVo);



$clientId = '[YOUR API KEY]';
$userId = 428623;

// get tracks by user id
$userTracksVoMany = \Cirrus\Users\UsersCirrus::init()
  ->setClientId($clientId)
  ->setId($userId)
  ->fetchTracksData();

var_dump($userTracksVoMany);

// or get all followers
$userFollowersVoMany = \Cirrus\Users\UsersCirrus::init()
  ->setClientId($clientId)
  ->setId($userId)
  ->fetchFollowersData();

var_dump($userFollowersVoMany);



$clientId = '[YOUR API KEY]';
$trackId = 64321366;

$trackVo = \Cirrus\Tracks\TracksCirrus::init()
  ->setClientId($clientId)
  ->setId($trackId)
  ->fetchData();

var_dump($trackVo);

$trackVo = \Cirrus\Tracks\TracksCirrus::init()
  ->setClientId($clientId)
  ->setId($trackId)
  ->withCompleteUserData(TRUE)
  ->fetchData();

\Cirrus\Users\UsersCirrus

\Cirrus\Users\UsersCirrus::init()
  ->setClientId($clientId)
  ->setId($userId)
  ->fetchData();

\Cirrus\Tracks\TracksCirrus

\Cirrus\Users\TracksCirrus::init()
  ->setClientId($clientId)
  ->setId($trackId)
  ->fetchData();

\Cirrus\Tracks\PlaylistsCirrus

\Cirrus\Users\PlaylistsCirrus::init()
  ->setClientId($clientId)
  ->setId($playlistId)
  ->fetchData();

array(
  'original' => 'original',
  '500'      => 't500x500',
  '400'      => 'crop',
  '300'      => 't300x300',
  '100'      => 'large',
  '67'       => 't67x67',
  '47'       => 'badge',
  '32'       => 'small',
  '20'       => 'tiny_artworks', // only artworks
  '18'       => 'tiny_avatars',  // only avatars
  '16'       => 'mini',
);



$clientId = '[YOUR API KEY]';
$userId = 428623;

$userVo = \Cirrus\Users\UsersCirrus::init()
  ->setClientId($clientId)
  ->setId($userId)
  ->fetchData();

// set image size to 400x400
\Cirrus\Cirrus::getImageUrlBySize($userVo->getUrlAvatar(), 400); // http://i1.sndcdn.com/avatars-000000788968-kgr595-crop.jpg?e2f8ae2



$clientId = '[YOUR API KEY]';
$trackId = 64321366;

$trackVo = \Cirrus\Tracks\TracksCirrus::init()
  ->setClientId($clientId)
  ->setId($trackId)
  ->fetchData();

// set image size to original size
\Cirrus\Cirrus::getImageUrlBySize($trackVo->getUrlAvatar(), 'original'); // http://i1.sndcdn.com/artworks-000032638740-ttuwkl-original.jpg?e2f8ae2
withCompleteUserData(TRUE)
withTracksData(TRUE)
withPlaylistsData(TRUE)
withFollowersData(TRUE)
withFollowingsData(TRUE)
withFavoritesData(TRUE)
withCompleteUserData(TRUE)
withCompleteUserData(TRUE)
config.php.dist
config.php