Create the SOAP client
$client = new SoapClient("https://Service.BlackboardConnect.com/Contact/v2/ContactService.asmx?wsdl",array ('trace' => 1));Create Authorization Header
//ParametersI had to strip the header tag for the xml
$options = array(
'DATE' => gmdate("Ymd"),
'TIME' => gmdate("Hi"),
'API' => '*API KEY*',
'SECRET => '*API SECRET*');
//Hash Parameters
$hash = md5(strtoupper($options['API']) . '|' . $options['SECRET'] . '|' . $options['DATE'] . '|' . $options['TIME']);
//Create Token
$authtoken = trim($hash . '|' . $options['API']);
$headerbody = array('Token' => $authtoken);
//Set SOAP Header
$header = new SOAPHeader('BBConnect.Service.Contact', 'AuthToken', $headerbody);
$client -> __setSoapHeaders($header);
$xml = simplexml_load_file(*path to file*);Create SOAP Variable
$convert = $xml->asXML();
$xmldata = str_replace('<?xml version="1.0" encoding="UTF-8"?>', '', $convert);
$input = new SoapVar( $xmldata, XSD_ANYXML );Submit Request
try {Get Response
$request = new StdClass();
$request->inputXml = (object) array('any' => $input );
$response = $client->UpdateContact($request);
} catch (Exception $e) {
echo "<h2>Exception Error!</h2>";
echo $e -> getMessage();
}
echo "<h3>RESPONSE:</h3>";Debug Request/Header
echo htmlspecialchars($client->__getLastResponse());
echo "<h3>REQUEST:</h3>";Blackboard Connect 5 API Documentation
echo htmlspecialchars($client->__getLastRequest());
echo "<h3>REQUEST HEADERS:</h3>";
echo htmlspecialchars($client->__getLastRequestHeaders());
Pretty straight forward, if you have any questions let me know.
No comments:
Post a Comment