Skip to content

Commit

Permalink
[ADDED] JSONP support for MPOS API
Browse files Browse the repository at this point in the history
Fixes #1700 once merged.

Thanks @spliznork for the feature request and solution.
  • Loading branch information
MPOS123 committed Feb 7, 2014
1 parent 93470fd commit a03b9d4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion public/include/classes/api.class.php
Expand Up @@ -28,13 +28,17 @@ function isActive($error=true) {
* @return string JSON object * @return string JSON object
**/ **/
function get_json($data, $force=false) { function get_json($data, $force=false) {
return json_encode( $json = json_encode(
array( $_REQUEST['action'] => array( array( $_REQUEST['action'] => array(
'version' => $this->api_version, 'version' => $this->api_version,
'runtime' => (microtime(true) - $this->dStartTime) * 1000, 'runtime' => (microtime(true) - $this->dStartTime) * 1000,
'data' => $data 'data' => $data
)), $force ? JSON_FORCE_OBJECT : 0 )), $force ? JSON_FORCE_OBJECT : 0
); );
// JSONP support issue #1700
if (isset($_REQUEST['callback']))
return $_REQUEST['callback'] . '(' . $json . ');';
return $json;
} }


/** /**
Expand Down

0 comments on commit a03b9d4

Please sign in to comment.