API and JSONP

15 views
Skip to first unread message

Nicolas Lehmann

unread,
Jun 12, 2011, 8:25:54 AM6/12/11
to yourTwapperKeeper, Wolfgang Reinhardt
Hi it would be great if the API of yourTwapperKeeper would support
JSONP Calls.
All you have to change is in the apiListArchives.php from:

header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
echo json_encode($result);

To

header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
$data = json_encode($result);
if( $_GET['jsonp_callback'] ) {
echo $_GET['jsonp_callback'] . '(' . $data . ');';
} else {
echo $data;
}
and similar in the apiGetTweets.php from:

echo json_encode($response);

To:
$data = json_encode($response);
if( $_GET['jsonp_callback'] ) {
echo $_GET['jsonp_callback'] . '(' . $data . ');';


Cheers
Nicolas Lehmann
Reply all
Reply to author
Forward
0 new messages