Download the PHP package edwindayot/echonest without Composer
On this page you can find all versions of the php package edwindayot/echonest. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download edwindayot/echonest
More information about edwindayot/echonest
Files in edwindayot/echonest
Package echonest
Short Description PHP Library for Echonest API including usefull methods.
License MIT
Homepage https://github.com/edwindayot/echonest
Informations about the package echonest
Echonest API
So here you are, searching for usefull methods to request the Echonest API with a speak-like language. This Echonest Library helps you in this way, take a look :
Initializing
First of all, you need to initialize the Echonest Library, just do it like this:
And that's it, you've got your Echonest instance ! The only next thing to do is to give it as a parameter of the API category you want to use. Let's say you want to use the Artist category:
Requesting
Now, you'll be able to make all of your requests very simply. Let's say you want to search an artist which name is "Martin Garrix":
With only this, you'll get the QueryBuilder instance, there is many methods you can use with the Fluent model. For instance, you could just want the Spotify's datas for this artist, so you can say:
There you are, now, you've got your QueryBuilder instance, and the only thing to do now is to get the Query results:
Now, your martin_garrix is a collection, and there is a couple thing you can do at this point. The thing you'll use the most is the array transformation of the collection.
That's it, you've got your array.
These methods matches to the Echonest API specifications, so if you want to understand what is an id, or whatever, please refer to http://developer.echonest.com/docs/v4/.
So, since the get()
method is launched, the QueryBuilder instance become an EchonestColletion instance, so the methods from the QueryBuilder aren't available anymore. Here is a list of the available methods for each API Category, for the QueryBuilder, and for the EchonestCollection:
Artists
Songs
Genres
Tracks
Query
Collection
Of course, the last method toArray()
isn't necessary because of the ArrayAccess implements. The EchonestCollection var 'items' values are accessible as an array:
Works fine as this:
So the toArray()
is necessary only if you want to return it as json or xml for instance.
Enjoy ! (Do not forget to report any bug you found, and please tell me about the new features you want !)