Response Formats
Each call to Osmek will return data in one of the following formats, based upon what you specify via the format parameter in your request. If format is not specified JSON will be returned. Example: &format=custom.
JSON
A JSON formatted response. Useful for use with Javascript.
Examples:
After posting the following variables to http://api.osmek.com/feeds:
api_key=[removed]§ion_id=932&format=json&limit=1
The response from Osmek will be something like:
{
"total":1,
"items": [
{
"id":"9952",
"sect_id":"932",
"c_sort":"0",
"date_added":"2009-12-22 21:15:19",
"date":"2009-12-22 21:15:19",
"flag":null,
"title":"Lorem Ipsum Dolor",
"url_title":"Lorem-Ipsum-Dolor",
"postbody":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque felis tellus, tincidunt id vulputate ac, iaculis sed velit.",
"photo":null,
"file":null,
"active":"1",
"author":"1",
"allow_comments":"1",
"date_stamp":"1261538119",
"comment_count":"0"
}
]
}
For feeds requested as JSON or PHP, all available data will be included in the response. If you include the parameter vars in your call you can specity what variables you want, and how their values should be formatted. The vars parameter should be a list of variable keywords as a pipe ("|") delimited string.
Adding a vars parameter will limit the data in the results. Posting the following variables yields the following response:
api_key=[removed]§ion_id=932&format=json&limit=1&vars=date|title
{"total":1,"items":[{"date":"2009-12-22 21:15:19","title":"Lorem Ipsum Dolor"}]}
PHP
Osmek will return your feeds formatted as a serialized PHP array. You can use PHP's unserialize function to convert the response to a usable PHP array.
Examples:
After posting the following variables to http://api.osmek.com/feeds:
api_key=[removed]§ion_id=932&format=php&limit=1&vars=date|title
// If $response is the response from Osmek
$response = unserialize($response);
var_dump($response);
// Will display:
array(2) {
["total"]=>
int(1)
["items"]=>
array(1) {
[0]=>
array(2) {
["date"]=>
string(19) "2009-12-22 21:15:19"
["title"]=>
string(26) "Lorem Ipsum Dolor"
}
}
}
XML
Osmek will return your feeds in preformatted XML. This can be usefull for use in flash.
HTML
Osmek will return your feeds in preformatted HTML. This can be usefull for a quick HTML site.
Custom
The custom option allows you to specify a template using the parameter template. Learn more about templates in the Templates & Keywords section.
Example:
After posting the following variables to http://api.osmek.com/feeds:
api_key=[removed]§ion_id=932&format=custom&limit=1&template=<h2>[title]</h2><span class="date">[date]</span>
The response will be something like:
<h2>Lorem Ipsum Dolor</h2><span class="date">2009-12-22 21:15:19</span>