User Patch: If a callback is not given, then just provide the raw JSON.

Submitted by Ross Masters <ross@rossmasters.com>
This commit is contained in:
Martin Konecny 2012-07-17 14:47:13 -04:00
parent 1e76845e9c
commit eba4b688c4

View file

@ -296,7 +296,9 @@ class ApiController extends Zend_Controller_Action
$result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; //used by caller to determine if the airtime they are running or widgets in use is out of date.
header("Content-type: text/javascript");
echo $_GET['callback'].'('.json_encode($result).')';
// If a callback is not given, then just provide the raw JSON.
echo isset($_GET['callback']) ? $_GET['callback'].'('.json_encode($result).')' : json_encode($result);
} else {
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource. ';
@ -329,7 +331,9 @@ class ApiController extends Zend_Controller_Action
}
$result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; //used by caller to determine if the airtime they are running or widgets in use is out of date.
header("Content-type: text/javascript");
echo $_GET['callback'].'('.json_encode($result).')';
// If a callback is not given, then just provide the raw JSON.
echo isset($_GET['callback']) ? $_GET['callback'].'('.json_encode($result).')' : json_encode($result);
} else {
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource. ';