Skip to content

Instantly share code, notes, and snippets.

@romainbessugesmeusy
Created February 22, 2013 10:05
Show Gist options
  • Save romainbessugesmeusy/5012251 to your computer and use it in GitHub Desktop.
Save romainbessugesmeusy/5012251 to your computer and use it in GitHub Desktop.
ExpressConnect Test
<?php
$payload = file_get_contents('TEST.xml');
$ch = curl_init("https://iconnection.tnt.com/ShipperGate2.asp");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "xml_in=" . $payload);
curl_setopt($ch, CURLOPT_HEADER, 'Content-type: application/x-www-form-urlencoded');
curl_setopt($ch, CURLOPT_HEADER, 'User-Agent: ShipperGate_socket/1.0');
curl_setopt($ch, CURLOPT_HEADER, "Content-length: " . strlen("xml_in=" . $payload));
curl_setopt($ch, CURLOPT_HEADER, 'Accept: */*');
$result = curl_exec($ch);
echo "<h1>Posting a consignment</h1>";
echo "<pre>";
var_dump($result);
echo "</pre>";
echo "<h1>Getting the AccessCode back</h1>";
list($key, $accessCode) = explode(":", $result);
echo "<p>$accessCode</p>";
$ch = curl_init("https://iconnection.tnt.com/ShipperGate2.asp");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "xml_in=GETRESULT:$accessCode");
curl_setopt($ch, CURLOPT_HEADER, 'Content-type: text/xml');
curl_setopt($ch, CURLOPT_HEADER, 'User-Agent: ShipperGate_socket/1.0');
curl_setopt($ch, CURLOPT_HEADER, "Content-length: " . strlen("xml_in=GETRESULT:$accessCode"));
curl_setopt($ch, CURLOPT_HEADER, 'Accept: */*');
$result = curl_exec($ch);
echo "<h1>Calling GET_RESULT:$accessCode</h1>";
echo "<pre>";
var_dump($result);
echo "</pre>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment