In 'Your Active Web Service list' click on the application name to
have access to subscription details, including the PublicAccessID
and the SecretAuthKey
Replace the PublicAccessID and SecretAuthKey in the code snippet below
with yours data.
The PublicAccessID key is sent as clear text, and is used to identify
both user and application. Our platform uses an hash based verification system
to check the data integrity and the user identity.
The SecretAuthKey is only used locally to generate the hash, and it's
never transmitted over the network. You never have to send it. Keep it secret!
<?php
$xmlResponse = wsMarkupCleanerExample("<br/>This is an example<br/>");
$xmlObject = simplexml_load_string($xmlResponse);
// Do something here
function wsMarkupCleanerExample($text) {
$rService = 'txp';
$rType = 'mkc';
$pText = $text;
$pType = 'plain';
$publicAccessID = '0123456789012345678901234567890123456789012345678901234567890123';
$secretAuthKey = '9876543210987654321098765432109876543210987654321098765432109876';
$strToHash = $rService . $rType . $pText;
$authWSControlKey = hash_hmac('sha256', $strToHash, $secretAuthKey);
$data = array( 'rService' => $rService,
'rType' => $rType,
'pText' => $pText,
'pType' => $pType,
'authWSControlKey' => $authWSControlKey,
'publicAccessID' => $publicAccessID
);
$data = http_build_query($data);
// US-Datacenter-Endpoint
$endPoint = "http://us.ws.complexityintelligence.com/rest/txp/markupcleaner/v1";
// EU-Datacenter-Endpoint
// $endPoint = "http://eu.ws.complexityintelligence.com/rest/txp/markupcleaner/v1";
$reply = do_post_request($endPoint, $data);
return($reply);
}
function do_post_request($url, $data, $optional_headers = null) {
$params = array('http' => array(
'method' => 'POST',
'content' => $data
));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Error: $url, $php_errormsg");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Error: $url, $php_errormsg");
}
return $response;
}
?>