-
-
Save kehh/f36cb168d398de12bdeb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Example usage (using jQuery): | |
* var url = "/path/mantisconnect_json.php?name=mc_project_get_issues&project_id=0&page_number=1&per_page=10"; | |
* $.getJSON(url, function(data) { | |
* $.each(data, function() { | |
* console.log(data.id + ': ' data.summary); | |
* }); | |
* }); | |
*/ | |
// URL to your Mantis SOAP API (the mantisconnect.php file) | |
define('MANTISCONNECT_URL', 'http://www.whereyouhaveyourmantis.com/api/soap/mantisconnect.php'); | |
// the username/password of the user account to use for calls | |
define('USERNAME', 'yourmantislogin'); | |
define('PASSWORD', 'yourmantisloginpassword'); | |
// ------------------------------------------------ | |
parse_str($_SERVER['QUERY_STRING'], $args); | |
// get SOAP function name to call | |
if (!isset($args['name'])) { | |
die("No name specified."); | |
} | |
$function_name = $args['name']; | |
// remove function name from arguments | |
unset($args['name']); | |
// prepend username/passwords to arguments | |
$args = array_merge( | |
array( | |
'username' => USERNAME, | |
'password' => PASSWORD | |
), | |
$args | |
); | |
// connect and do the SOAP call | |
try { | |
$client = new SoapClient(MANTISCONNECT_URL . '?wsdl'); | |
$result = $client->__soapCall($function_name, $args); | |
} catch (SoapFault $e) { | |
$result = array( | |
'error' => $e->faultstring | |
); | |
} | |
print json_encode($result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment