PHP code example of edwindayot / echonest

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

    

edwindayot / echonest example snippets




  use Echonest\Facade\Echonest;

  $echonest = Echonest::init('YOUR_API_KEY');



  use Echonest\Facade\EchonestArtists;
  
  $artists = new EchonestArtists($echonest);



  $artists->getSearch()->setName('Martin Garrix');



  $artists->getSearch()
    ->setName('Martin Garrix')
    ->setBucket('id:spotify');



  $martin_garrix = $artists->getSearch()
    ->setName('Martin Garrix')
    ->setBucket('id:spotify')
    ->get();



  $martin_garrix = $artists->getSearch()
    ->setName('Martin Garrix')
    ->setBucket('id:spotify')
    ->get()
    ->toArray();



  use Echonest\Facade\EchonestArtists;

  $artists->getBiographies($name);
  $artists->getBiographiesById($id);
  $artists->getBlogs($name);
  $artists->getBlogsById($id);
  $artists->getFamiliarity($name);
  $artists->getFamiliarityById($id);
  $artists->getHotttnesss($name);
  $artists->getHotttnesssById($id);
  $artists->getImages($name);
  $artists->getImagesById($id);
  $artists->getListTerms();
  $artists->getNews($name);
  $artists->getNewsById($id);
  $artists->getProfile($name);
  $artists->getProfileById($id);
  $artists->getReviews($name);
  $artists->getReviewsById($id);
  $artists->getSearch();
  $artists->getExtract($text);
  $artists->getSongs($name);
  $artists->getSongsById($id);
  $artists->getSimilar($name);
  $artists->getSimilarById($id);
  $artists->getSuggest($name);
  $artists->getTerms($name);
  $artists->getTermsById($id);
  $artists->getTopHottt();
  $artists->getTopTerms();
  $artists->getTwitter($name);
  $artists->getTwitterById($id);
  $artists->getUrls($name);
  $artists->getUrlsById($id);
  $artists->getVideo($name);
  $artists->getVideoById($id)



  use Echonest\Facade\EchonestSongs;

  $songs->getArtistSongs($name);
  $songs->searchSongs($title);
  $songs->getSongProfile($id);



  use Echonest\Facade\EchonestGenres;

  $genres->getArtists($name);
  $genres->getList();
  $genres->getProfile($name);
  $genres->getSearch($name);
  $genres->getSimilar($name);



  use Echonest\Facade\EchonestTracks;
  
  $tracks->getTrackProfile($id);
  $tracks->getUploadTrack($url);
  $tracks->postUploadTrack($url);



  $echonest->queryBuilder
    ->setApi('category_name')
    ->setCommand('method_name')
    ->setName('a name') // alias for setOption('name', 'a name')
    ->setId('anID') // alias for setOption('id', 'anID')
    ->setBucket('a_bucket') // alias for setOption('bucket', 'a_bucket')
    ->sortBy('a_sort_option', 'desc') // alias for setOption('sort', 'a_sort_option-desc')
    ->setOption('option_name', 'value')
    ->limit(3) // get 3 elements (0, 1, 2)
    ->limit(3, 2) // get 3 elements starting from 3rd base element (2, 3, 4)
    ->get();



  $artists->get()
    ->has('artists') // return bool
    ->orderBy('name')
    ->toArray(); // return the array transformed values of $items


  $array = $artists->get();
  
  echo $array['artists'];


  $array = $artists->get();
  
  foreach ($array as $key => $value) {
    echo "$key = $value";
  }