Skip to content
m3nt0r edited this page Sep 13, 2010 · 3 revisions

Download the latest version and place the lastfm_source.php file into your app/models/datasources/ folder.

Configuration

Open your database.php file in your app/config folder. Now add a new property called ‘lastfm’ like so:

 	  var $lastfm = array(
 		'datasource' => 'lastfm',
 		'apikey' => 'YOUR_API_KEY',
 		'secret' => 'YOUR_API_SECRET'
 	  );

Replace YOUR_API_KEY with the key you obtained from the last.fm API account page. Same goes for YOUR_API_SECRET. Save and close the file.

Create a Model file

Create a new Model which is using this datasource. This model needs no table in your database. Just create a new file in your app/models folder. For example: lastfm.php

 	  class Lastfm extends AppModel { 
 		var $useDbConfig = 'lastfm'; 
 	  }

This is all you need to do. Save and close the file.

Create a Controller file

Create a new Controller which is using the model we’ve just created. Create a new file in your app/controllers folder. For example: lastfms_controller.php which would follow the CakePHP conventions since we named the model Lastfm. But everything else works too. Just make sure you can access the Model somehow.

 	  class LastfmController extends AppController { 
 		var $uses = array('Lastfm'); 
 	  }

Clone this wiki locally