I am using CakePHP 1.3. I have successfully created an Indeed DataSource and am looking to create more complicated ones. I am looking into creating a Yahoo Answers DataSource and was wondering about a few best practices. The API exposes a few functions:
1) Ability to search for questions
2) Ability to get questions in a category
3) Ability to get details on a specific question
4) Ability to get details on a specific user
As is, I might only use the question and user search functions. Here are my questions:
-
Do I created 1 DataSource that can perform both tasks or separate ones (i.e. one to find users and another to find questions?
-
If i create 1 DataSource then how do I identify if the model is $this->YahooUser->find() (find users) vs $this->YahooQuestion->find() (find questions) so that I may create the right URL for the request.
Think of a datasource as a Database. For example, CakePHP is distributed with several database-specific datasources (ie. MySql, Oracle, etc.) What you will want to do is create a YahooAnswers datasource.
Here is an example in the docs to show you how to create a Twitter datasource for example:
http://book.cakephp.org/view/849/An-Example
This should help you implement the YahooAnswers API as a datasource.
UPDATE: Here is an example: