Datasources in Cake / [ANN] Last.FM Source
Some who follow me on twitter might know that i don’t sleep so well recently. But why waste time then? Maybe one isn’t ready for working on the big projects around 3am, but chances are that you can at least do something by reading the cookbook or just messing around with your favorite Framework.
Yesterday i finally looked into datasources. I recently tagged my Amazon Component as deprecated, simply because it is not “how it’s done” anymore. With Amazon you can find products, lists, reviews (short: data), so it’s obviously a data-source and nothing else. Same goes for all other APIs that offer data. So i urge any cakephp dev to look into datasources. Convert your existing components to sources if they are ment to fetch data from elsewhere.
Announcement: Last.FM Datasource
Last.FM tracks what you play on your mp3-player and logs your plays into charts. It uses the generated stats to find songs you don’t know but probably like, based on what other users listen who also listen to songs you listen. This works pretty well after you gave the service some time to adjust to your taste. The song/artist data is combined with a wiki, events, comments, images and tags. There are also usergroups. Each group has it’s own taste based on users in that group and that makes it even more interesting. The list goes on..
Well, it’s not the first time i played with their API and because i am familiar with it, i thought it’s a good idea to use it for my first datasource. I admit that i haven’t looked up a thing on Datasources and CakePHP. But therefore i am pretty happy with the result. Basicly it works like this, using __call and query().
$result = $this->Model->Artist('search', array('artist' => 'cher', 'limit' => 10));
$user = $this->Model->User('getInfo', array('user' => 'foobar'));
The datasource is not fully tested yet, and authentication (pretty openid-like) may not work at all, but it is all layed out and just needs some tests. I will install the source on this webserver soon, set it up as auth callback url and do some debugging. This will show me what’s missing in regard of Auth and maintaining user sessions and allow me to test my POST requests. I am using HttpSocket and i am pretty sure that i won’t run into problems once i have the Session/Token/Signature-thing going.
If you feel like doing a code review, you can find the latest draft it on gitHub. (I give no support to people who just grab and use it on projects since this is just an announcement. I’ll let you know when it’s done.)


[...] Datasources in Cake / [ANN] Last.FM Source [...]