I needed to use my drupal site as web service to serve my android/iphone app.
The responses had to be in json format.
I knew about services module which can do the needful with json server enabled.
However for drupal 7, the documentation said that json server is built into the services core.
The documentation is JUST AWFUL
Anyways cutting the shit, here's how I got stuff working :
The responses had to be in json format.
I knew about services module which can do the needful with json server enabled.
However for drupal 7, the documentation said that json server is built into the services core.
The documentation is JUST AWFUL
Anyways cutting the shit, here's how I got stuff working :
- install services 3
- grab spyc library (this was the most irritating part) http://code.google.com/p/spyc/downloads/detail?name=spyc-0.5.zip
- from the download, copy spyc.php and paste it in modules/service/servers/rest/lib
- enable services module
- enable "rest server" module
- at this point Services may not appear in Structure. Run cron and Update script.
- go to structure->services->add
- give a unique name, an endpoint name (mine is "api") so in the textbox, just write "api" nothing else
- save and then open it to edit
- in the resources, check "node"
- permissions for "Node view" should be set to anonymous
- goto http://127.0.0.1/mysite/?q=api/node/1.json and it returns the json data of 1st node.
P.S. Are there no document writers contributing to the drupal project?
Comments
Post a Comment