From eba4b688c4a5de66d6174681f5decb336408a4da Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 17 Jul 2012 14:47:13 -0400 Subject: [PATCH] User Patch: If a callback is not given, then just provide the raw JSON. Submitted by Ross Masters --- airtime_mvc/application/controllers/ApiController.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 72900d873..b9d302008 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -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. ';