Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- ini_set('display_errors', '1');
- $showDebugInfo = TRUE;
- $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'.PHP_EOL;
- $xml .= '<PRICEREQUEST>'.PHP_EOL;
- $xml .='<LOGIN>'.PHP_EOL;
- $xml .= '<COMPANY>xxx</COMPANY>'.PHP_EOL;
- $xml .= '<PASSWORD>xxx</PASSWORD>'.PHP_EOL;
- $xml .= '<APPID>PC</APPID>'.PHP_EOL;
- $xml .= '</LOGIN>'.PHP_EOL;
- $xml .= '<DATASETS>'.PHP_EOL;
- $xml .='<COUNTRY>1.0</COUNTRY>'.PHP_EOL;
- $xml .= '<CURRENCY>1.0</CURRENCY>'.PHP_EOL;
- $xml .= '<POSTCODEMASK>1.0</POSTCODEMASK>'.PHP_EOL;
- $xml .='<TOWNGROUP>1.0</TOWNGROUP>'.PHP_EOL;
- $xml .='<SERVICE>1.0</SERVICE>'.PHP_EOL;
- $xml .='<OPTION>1.0</OPTION>'.PHP_EOL;
- $xml .='</DATASETS>'.PHP_EOL;
- $xml .='<PRICECHECK>'.PHP_EOL;
- $xml .='<RATEID>asasasasasasasas</RATEID>'.PHP_EOL;
- $xml .='<ORIGINCOUNTRY>GB</ORIGINCOUNTRY>'.PHP_EOL;
- $xml .='<ORIGINTOWNNAME></ORIGINTOWNNAME>'.PHP_EOL;
- $xml .='<ORIGINPOSTCODE></ORIGINPOSTCODE>'.PHP_EOL;
- $xml .='<ORIGINTOWNGROUP></ORIGINTOWNGROUP>'.PHP_EOL;
- $xml .='<DESTCOUNTRY>AU</DESTCOUNTRY>'.PHP_EOL;
- $xml .='<DESTTOWNNAME></DESTTOWNNAME>'.PHP_EOL;
- $xml .='<DESTPOSTCODE></DESTPOSTCODE>'.PHP_EOL;
- $xml .='<DESTTOWNGROUP></DESTTOWNGROUP>'.PHP_EOL;
- $xml .='<CONTYPE>D</CONTYPE>'.PHP_EOL;
- $xml .='<CURRENCY>GBP</CURRENCY>'.PHP_EOL;
- $xml .='<WEIGHT>0.2</WEIGHT>'.PHP_EOL;
- $xml .= '<VOLUME>0</VOLUME>'.PHP_EOL;
- $xml .= '<ITEMS>1</ITEMS>'.PHP_EOL;
- $xml .='</PRICECHECK>'.PHP_EOL;
- $xml .='</PRICEREQUEST>';
- try {
- /**
- * Content length,
- * Use strlen AFTER encoding.
- **/
- $EncodedHtml = htmlspecialchars( $xml );
- $XmlLength = ( strlen( $EncodedHtml ) + 7 );
- /**
- * Using the cURL
- * Module within PHP.
- *
- * Enable it via HTAccess.
- **/
- $ch = curl_init("https://express.tnt.com/expressconnect/pricing/getprice");
- if ( false === $ch )
- throw new Exception('failed to initialize');
- /**
- * cURL Options
- * - Use Program's Custom Headers
- * - Use \n to separate headers
- **/
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_PORT, 81 );
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1 );
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1 );
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
- // curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- // "POST PriceGate.asp HTTP/1.0\n",
- // "Accept: */*\n",
- // "User-Agent: PriceGate_socket/1.0\n",
- // "Content-type: application/x-www-form-urlencoded;\n",
- // "Content-length: ". ( $XmlLength ) ."\n",
- // "\n",
- // "xml_in=". $EncodedHtml.""
- // ));
- if ( $showDebugInfo ) {
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
- curl_setopt($ch, CURLOPT_FAILONERROR, true);
- }
- $output = curl_exec($ch);
- if ( false === $output )
- throw new Exception( curl_error( $ch ), curl_errno( $ch ));
- else
- echo $output;
- curl_close($ch);
- } catch( Exception $e ) {
- /**
- * Display All Errors!
- **/
- trigger_error(sprintf(
- 'Curl failed with error #%d: %s',
- $e->getCode(), $e->getMessage()), E_USER_ERROR);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement