Skip to content
Alban LEROUX edited this page Oct 3, 2011 · 6 revisions

Example with Query String

Request

This is requesting the photo 123456 informations: title, description and publish-date

Here we ask for json format in response but we can ask for xml format too. Same method is used with http POST method.

GET http://www.something.com/api/photo.get/json/?id=123456&fields[]=title&fields[]=description&fields[]=publish-date

Response

The requested data are provided like this:

{
	"status"   : "valid",
	"response" : 
	{
		"title"        : "My best photo",
		"description"  : "This photo was token ..."
		"publish-date" : "2011-08-24T12:33:42+01:00"
	}
}

Response Error

If an error occurs like an unknow photo id:

{
	"status"  : "error",
	"code"    : "no_result",
	"message" : "There is no photo corresponding to the 'id' : 123456"
}

How to deal with associated key / value

Some api method require associated key / value like photo.list.

Note associative key / value is this json example:

{
	"method"  : "photo.list",
	"request" : 
	{
		"fields" : [ "title", "thumb-url" ],
		"pager"  :
		{
			"page"         : 1,
			"max-per-page" : 10
		}
	}
}

Usual query string don't permit to send associated key / value like &pager[page]=1.

For thoses cases we use a sweet hack consist in join associative key / value with ::.

Here is the previous json exemple in query string format:

GET http://something.com/api/photo.list/json/?fields[]=title&fields[]=thumb-url&pager::page=1&pager::max-per-page=10

Clone this wiki locally