In my previous post I decided to make the Friends Gadget work on PHP Shindig. I managed to do so, thus I will stay with PHP version of Apache Shindig.
I will use the gadget that lists friends of the user. Notice that http://shindig/ is where you have your shindig installation (http://localhost:8080, for example). Here is the gadget code:
Now we want Apache Shindig to get a list of friends for a user with id=2 from my database 'graaasp_development'.
Here is a url that does it.
The most important parameter here is a "st" parameter, that stands for security token.
Owner_id means id of the owner of the gadget. Viewer_id means id the current user watching the gadget.
Application_id means the id of the gadget instance in the database.
In other words, in 'graaasp_development' database we have a gadget with id=12. Owner of this gadget is user with id=2 and the same user watches the gadget at the moment.
Now we have to add some code to shindig to let it know that 'graaasp_development' database should be used as a backend for gadgets requests.
First of all in the folder "shindig/php/config/" we should create a file 'local.php' with the following content.
This will force Shindig to use the code specific to the 'graaasp_development' database, which is located in '/Library/WebServer/Documents/graaasp'.
Now we have to rewrite the classes that will respond to opensocial code with data from 'graaasp_development' database.
1) in the file config.php we should change the database settings as follows:
2) In file PartuzaDbFetcher.php we have the code that gets friends from 'graaasp_development' database.
The output of the widget will be similar to the following:
Friends of User1:
* Guest
* User2
* User3
No comments:
Post a Comment