FREIGHT CALCULATION for WEBSPEED

Anki

New Member
Hi guys, i currently create an website but i dont know how to insert Freight calculation into my website. Can you guys give me some advise with i should use? I do research and see people using AUS Post API but the code is PHP and i dont know how to get it into webspeed. Can we do it?
 

TomBascom

Curmudgeon
Perhaps if you showed a little sample code that helps to illustrate what you have tried and where you are having trouble we could be of better assistance.
 

Cecil

19+ years progress programming and still learning.
Hi Anki,

Question:
Which version of OpenEdge are you using and operating system?

I just did a quick look at the AUS post website, is it this API code you are interested in?
https://developers.auspost.com.au/apis/pac/tutorial/international-parcel

I see that there is several API calls you can make for a particular services the AUS post provides. The only PHP code I see so far is just to make calls to cURL library which handles to the the HTTP requests for Authentication and GET requests.

Depending of the version of OpenEdge and OS you could make the relevant API calls using .NET if you are using Windows to run your Web Server. Or shell out to the OS can call cURL command line tool for Linux and Windows.

It tricky to do a direct comparison of the PHP code because it's dam near impossible to access the cURL library in OpenEdge. Not to go a personal rant but OpenEdge has big lacking feature to make HTTP/S capabilities within the ABL language.

I recommend using cURL command line tool to issue the GET requests and get the response in the form of an XML. Using OE SAX parser to parse the XML server response. You can use the SAX Parser to access URLs, however it does not support the extra HTTP headers which would be required to make the necessary calls to AUS Post API.

For a ABL solution for handling HTTP GET request is to use the code from github. https://github.com/Jimbobnz/ABL-HTTP-Web-Request I won't recommend using it because I wrote it. The project is currently mothballed, it does work I need more testing and development of the code.
https://github.com/Jimbobnz/ABL-HTTP-Web-Request



https://developers.auspost.com.au/apis/pac/tutorial/international-parcel
https://developers.auspost.com.au/apis/pac/tutorial/international-parcel
 

Cecil

19+ years progress programming and still learning.
I could not resist myself. Here is the code for calling AUS Post API using the ABL-HTTP-Web-Request class object if you want to use it.

The code only handles the call to the AUS Post API. It does not process the server response..

Also I have a spelling mistake for the word Response for the class objects.

Code:
USING co.dsg.http.*.

DEFINE VARIABLE objHttp             AS CLASS http         NO-UNDO.
DEFINE VARIABLE objHttpRequest      AS CLASS httpRequest  NO-UNDO.
DEFINE VARIABLE objHttpResponce     AS CLASS httpResponce NO-UNDO.

/* Create a new HTTP Client class object. */
objHttp        = NEW http().
/* Create a new HTTP Client Request class object. */
objHttpRequest = NEW httpRequest().

/** Set the HTTP Request Method to 'GET' **/
objHttpRequest:HttpMethod = 'GET'.

/** Enter the AUS Post API Auth Key here....**/
objHttpRequest:AddHeader('AUTH-KEY', 'abcd1234foobar').

objHttpRequest:AddParam('from_postcode','2055'). /* Somewhere is Sydney*/
objHttpRequest:AddParam('to_postcode','3000').
objHttpRequest:AddParam('length','18'). /** 18CM **/
objHttpRequest:AddParam('width','23'). /** 23CM **/
objHttpRequest:AddParam('height','12'). /** 12CM **/
objHttpRequest:AddParam('weight','0.5). /** 500g (Half Kilo)**/

/** Depending on what SERVER response you require either JSON or XML, comment/un-comment the following code. **/

/** Expecting and JSON response **/
/* objHttpRequest:AddHeader('Accept','application/json').               */
/* objHttpRequest:path = '/api/postage/letter/domestic/thickness.json'. */

/** Expecting and XML response **/
objHttpRequest:AddHeader('Accept', 'text/xml').
objHttpRequest:path = '/api/postage/parcel/domestic/size.xml'.  /* see the AUS Post API for more details.. */

/* This returns a HTTP Reponce class object  */
objHttpResponce = objHttp:SynchronousRequest( 'https://auspost.com.au', objHttpRequest ).

/** Your server response is here...**/
MESSAGE
    STRING( objHttpResponse:body )
    VIEW-AS ALERT-BOX INFO.

DELETE OBJECT objHttpRequest.
DELETE OBJECT objHttp.
 

Cecil

19+ years progress programming and still learning.
Hi Anki, Just out of curiosity, did you managed to come up with a solution to your issue?
 
Top