Twitter-compatible API - JSONP callbacks for all methods emitting JSON
darcs-hash:20080910025013-7b5ce-95c8dd7eaf83e98e5ee0da5dee8ef07fe4ae5041.gz
This commit is contained in:
parent
6eb84f0f03
commit
219927cb79
@ -208,11 +208,17 @@ class TwitterapiAction extends Action {
|
|||||||
function init_document($type='xml') {
|
function init_document($type='xml') {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
header('Content-Type: application/xml; charset=utf-8');
|
header('Content-Type: application/xml; charset=utf-8');
|
||||||
common_start_xml();
|
common_start_xml();
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
|
|
||||||
|
// Check for JSON-P callback
|
||||||
|
$callback = $this->arg('callback');
|
||||||
|
if ($callback) {
|
||||||
|
print $callback . '(';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'rss':
|
case 'rss':
|
||||||
header("Content-Type: application/rss+xml; charset=utf-8");
|
header("Content-Type: application/rss+xml; charset=utf-8");
|
||||||
@ -226,16 +232,22 @@ class TwitterapiAction extends Action {
|
|||||||
$this->client_error(_('Not a supported data format.'));
|
$this->client_error(_('Not a supported data format.'));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function end_document($type='xml') {
|
function end_document($type='xml') {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
common_end_xml();
|
common_end_xml();
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
|
|
||||||
|
// Check for JSON-P callback
|
||||||
|
$callback = $this->arg('callback');
|
||||||
|
if ($callback) {
|
||||||
|
print ')';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'rss':
|
case 'rss':
|
||||||
$this->end_twitter_rss();
|
$this->end_twitter_rss();
|
||||||
|
Loading…
Reference in New Issue
Block a user