From a03b9d4acec9597a0f3db5c2d00c97018c0d6c7c Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 7 Feb 2014 09:00:09 +0100 Subject: [PATCH] [ADDED] JSONP support for MPOS API Fixes #1700 once merged. Thanks @spliznork for the feature request and solution. --- public/include/classes/api.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/public/include/classes/api.class.php b/public/include/classes/api.class.php index be57fbbf..8e245a22 100644 --- a/public/include/classes/api.class.php +++ b/public/include/classes/api.class.php @@ -28,13 +28,17 @@ class Api extends Base { * @return string JSON object **/ function get_json($data, $force=false) { - return json_encode( + $json = json_encode( array( $_REQUEST['action'] => array( 'version' => $this->api_version, 'runtime' => (microtime(true) - $this->dStartTime) * 1000, 'data' => $data )), $force ? JSON_FORCE_OBJECT : 0 ); + // JSONP support issue #1700 + if (isset($_REQUEST['callback'])) + return $_REQUEST['callback'] . '(' . $json . ');'; + return $json; } /**