Post by beetlepod » Tue Jul 27, 2010 11:44 am

Hi

I'm trying to write a TNT express module for Australia but really don't know enough about PHP or POSTing.'

The TNT documentation supplies the following but when I try to formulate like the auspost or fastway modules

curl_setopt($ch,CURLOPT_UR:,'https://tntexpress.com.au/rtt/inputRequest.asp?username=user&password=pass&version=2&xmlRequest=...')

I get a simple
XML Invalid: XML document must have a top level element.
Can someone please point me in the right direction?

Thanks in Advance.

Peter



TNTExpress Example
---
POST /rtt/inputRequest.asp HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 1767
Host: www.tntexpress.com.au

username=user&password=pass&version=2&xmlRequest=%3C%3Fxml+version%3D%221.0%22%3F%3E%0D%0A%3Cenquiry+xmlns%3D%22http%3A%2F%2Fwww.tntexpress.com.au%22%3E%0D%0A++%3CratedTransitTimeEnquiry%3E%0D%0A++++%3CcutOffTimeEnquiry%3E%0D%0A++++++%3CcollectionAddress%3E%0D%0A++++++++%3Csuburb%3ESydney%3C%2Fsuburb%3E%0D%0A++++++++%3CpostCode%3E2000%3C%2FpostCode%3E%0D%0A++++++++%3Cstate%3ENSW%3C%2Fstate%3E%0D%0A++++++%3C%2FcollectionAddress%3E%0D%0A++++++%3CdeliveryAddress%3E%0D%0A++++++++%3Csuburb%3EMelbourne%3C%2Fsuburb%3E%0D%0A++++++++%3CpostCode%3E3000%3C%2FpostCode%3E%0D%0A++++++++%3Cstate%3EVIC%3C%2Fstate%3E%0D%0A++++++%3C%2FdeliveryAddress%3E%0D%0A++++++%3CshippingDate%3E2007-11-05%3C%2FshippingDate%3E%0D%0A++++++%3CuserCurrentLocalDateTime%3E%0D%0A++++++++2007-11-05T10%3A00%3A00%0D%0A++++++%3C%2FuserCurrentLocalDateTime%3E%0D%0A++++++%3CdangerousGoods%3E%0D%0A++++++++%3Cdangerous%3Efalse%3C%2Fdangerous%3E%0D%0A++++++%3C%2FdangerousGoods%3E%0D%0A++++++%3CpackageLines+packageType%3D%22D%22%3E%0D%0A++++++++%3CpackageLine%3E%0D%0A++++++++++%3CnumberOfPackages%3E1%3C%2FnumberOfPackages%3E%0D%0A++++++++++%3Cdimensions+unit%3D%22cm%22%3E%0D%0A++++++++++++%3Clength%3E20%3C%2Flength%3E%0D%0A++++++++++++%3Cwidth%3E20%3C%2Fwidth%3E%0D%0A++++++++++++%3Cheight%3E20%3C%2Fheight%3E%0D%0A++++++++++%3C%2Fdimensions%3E%0D%0A++++++++++%3Cweight+unit%3D%22kg%22%3E%0D%0A++++++++++++%3Cweight%3E1%3C%2Fweight%3E%0D%0A++++++++++%3C%2Fweight%3E%0D%0A++++++++%3C%2FpackageLine%3E%0D%0A++++++%3C%2FpackageLines%3E%0D%0A++++%3C%2FcutOffTimeEnquiry%3E%0D%0A++++%3CtermsOfPayment%3E%0D%0A++++++%3CsenderAccount%3E20003583%3C%2FsenderAccount%3E%0D%0A++++++%3Cpayer%3ES%3C%2Fpayer%3E%0D%0A++++%3C%2FtermsOfPayment%3E%0D%0A++%3C%2FratedTransitTimeEnquiry%3E%0D%0A%3C%2Fenquiry%3E%0D%0A


---

Newbie

Posts

Joined
Mon May 31, 2010 9:09 am

Post by beetlepod » Thu Jul 29, 2010 9:52 am

Never mind I have worked it out. :crazy:

Newbie

Posts

Joined
Mon May 31, 2010 9:09 am

Post by thesexyboi » Sat Jul 31, 2010 7:02 pm

do you have the module available for download

Newbie

Posts

Joined
Fri Jun 25, 2010 3:34 pm

Post by ncrsystems » Fri Sep 10, 2010 3:35 pm

is it available for download?, i have a version thats for 1.3.4 but i need one for 1.4.9

Newbie

Posts

Joined
Fri Sep 10, 2010 1:58 pm
Location - Australia

Post by Blurry » Tue Feb 08, 2011 12:22 pm

Hello,

Does anyone have an update on this? Anyone willing to fix it? (free or otherwise)

That module would be very handy as I would also like to use it.

Please contact me.

Thanks,
Blurry

Newbie

Posts

Joined
Sun Jan 30, 2011 12:10 pm

Post by beetlepod » Tue Feb 08, 2011 1:01 pm

See i this helps you.... TNT is very fussy and not at all helpful in building interfaces to their API.

Code: Select all

	private function getTNTExpressxml($shipDate, $address, $length=1, $width=1, $height=1, $weight=1)
	{
			$request_xml = "<?xml version='1.0'?><enquiry xmlns='http://www.tntexpress.com.au'><ratedTransitTimeEnquiry><cutOffTimeEnquiry>";
			$request_xml .= "<collectionAddress><suburb>" . $this->config->get('tntexpress_suburb') . "</suburb><postCode>" . $this->config->get('tntexpress_postcode') . "</postCode><state>" . $this->config->get('tntexpress_state') . "</state></collectionAddress>";
			$request_xml .= "<deliveryAddress><suburb>" . $address['city'] . "</suburb><postCode>" . $address['postcode'] . "</postCode><state>" . $address['zone'] . "</state></deliveryAddress>";
			$request_xml .= "<shippingDate>" .$shipDate . "</shippingDate>";
			$request_xml .= "<userCurrentLocalDateTime>" .date(DATE_ATOM) ."</userCurrentLocalDateTime>";
			$request_xml .= "<dangerousGoods><dangerous>false</dangerous></dangerousGoods><packageLines packageType='N'><packageLine>";
			$request_xml .= "<numberOfPackages>1</numberOfPackages>";
			$request_xml .= "<dimensions unit='cm'><length>" . $length ."</length><width>" . $width ."</width><height>" . $length ."</height></dimensions>";
			$request_xml .= "<weight unit='kg'><weight>" . $weight ."</weight></weight></packageLine></packageLines></cutOffTimeEnquiry><termsOfPayment>";
			$request_xml .= "<senderAccount>" . $this->config->get('tntexpress_account_id')  ."</senderAccount><payer>S</payer></termsOfPayment></ratedTransitTimeEnquiry></enquiry>";
			
			$data = array ('xmlRequest' => $request_xml,  'username' => $this->config->get('tntexpress_account_username'), 'password' => $this->config->get('tntexpress_account_password'));
			$data = http_build_query($data);
			$data = str_replace('&','&',$data);
			$data = str_replace('+','%20',$data) ;
			$data = str_replace('%2F','/',$data) ;
			echo '<!--'.$request_xml.'-->';
			$TNTURL = "https://www.tntexpress.com.au/Rtt/inputRequest.asp";
			$ch = curl_init($TNTURL);
			curl_setopt($ch, CURLOPT_POST, 1);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
			curl_setopt($ch, CURLOPT_TIMEOUT, 60);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			return curl_exec($ch);
	}

Newbie

Posts

Joined
Mon May 31, 2010 9:09 am
Who is online

Users browsing this forum: No registered users and 2 guests