Last active
December 11, 2015 00:09
-
-
Save asimpkin/4514676 to your computer and use it in GitHub Desktop.
Simple PHP CURL XML for querying ServiceNow Incidents
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 | |
include("../common.inc.php"); // Contains definitions for INSTANCE, USER, PASS | |
$query=urlencode('active=true^stateNOT IN6,^priorityIN1,2'); // Active, NOT Resolved, Hi Priority INC | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, 'https://'.INSTANCE.'.service-now.com/incident_list.do?XML&useUnloadFormat=true&sysparm_query='.$query); | |
curl_setopt($ch, CURLOPT_HEADER, 0); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | |
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); | |
curl_setopt($ch, CURLOPT_USERPWD, USER.':'.PASS); | |
$data = curl_exec($ch); | |
curl_close($ch); | |
$inc = new SimpleXMLElement($data); | |
echo"<table border=0 cellpadding=3 cellspacing=0>"; | |
foreach($inc->incident as $v) { | |
echo "<tr><td>".$v->number."<td>".$v->priority."<td>".$v->short_description."<td>".$v->u_portfolio[display_value]; | |
} | |
echo"</table>"; | |
echo count($inc); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment