Launching the FedEx Web Page

From CometWiki

Jump to: navigation, search

Launching the FedEx Web Page

This tip contains information about launching the FedEx Airbill Tracking web page from Comet98. This example is a follow-up to the UPS example we included in the February 4, 1999 tip.

In order to launch the FedEx tracking program, you need to know the format of FedEx's CGI program. We visited the FedEx web site, chose the airbill tracking link for the U.S.A., entered a sample airbill number of 40012892471, and examined the resulting URL, which was:

 http://www.fedex.com/cgi-bin/track_it?airbills=40012892471&language=english&state=0&cntry_code=us&Request+Tracking+Info.x=88&Request+Tracking+Info.y=10

As you can see, the airbill number is imbedded in the URL. This link displays FedEx's results summary page.

We took this URL, broke it into several segments, and wrote the following MTB program to launch the FedEx airbill tracking page. Note the use of the CHR(95) function to create the imbedded underline characters in the URL.

 LENGTH 80 
 COMMON B$                            ! B$ is the airbill number
                                      ! If it's null, INPUT an airbill number
                                      ! Otherwise, assume that a value was
                                      ! passed in COMMON from another program
 LENGTH 254
 LOCAL A$,C$,D$,E$
 IF B$ = "" THEN                      ! If B$ is null, then
   PRINT (0) (ET)
   PRINT (0) "Enter airbill number:"  ! Display prompt
   INPUT (0) B$                       ! Input airbill number
   B$ = STRIP(B$)                     ! Strip blanks from airbill number
 ENDIF
 !
 IF B$ = "" THEN RUN "QMONITOR"       ! If it's still null, then quit
 !
 A$="http://www.fedex.com/cgi-bin/track" + CHR(95) + "it?airbills="
 C$="&language=english&state=0&cntry" + CHR(95) + "code=us&Request+Tracking+"
 D$="Info.x=88&Request+Tracking+Info.y=10"
 E$ = A$+B$+C$+D$
 PRINT (0) (LAUNCH=E$)  ! Launch the FedEx tracking page
 RUN "QMONITOR"

As this point, we noticed that FedEx provided a link to a results detail page. That URL is:

 http://www.fedex.com/cgi-bin/track_it?airbill_list=40012892471&kurrent_airbill=40012892471&language=english&cntry_code=us&state=0

Notice that the airbill number is imbedded twice in this URL. Here's the MTB program that launches the results detail page.

 LENGTH 80 
 COMMON B$                            ! B$ is the airbill number
                                      ! If it's null, INPUT an airbill number
                                      ! Otherwise, assume that a value was
                                      ! passed in COMMON from another program
 LENGTH 254
 LOCAL A$,C$,D$,E$
 !
 IF B$ = "" THEN                      ! If B$ is null, then
   PRINT (0) (ET)
   PRINT (0) "Enter airbill number:"  ! Display prompt
   INPUT (0) B$                       ! Input airbill number
   B$ = STRIP(B$)                     ! Strip blanks from airbill number
 ENDIF
 !
 IF B$ = "" THEN RUN "QMONITOR"       ! If it's still null, then quit
 !
 A$="http://www.fedex.com/cgi-bin/track"+CHR(95)+"it?airbill"+CHR(95)+"list="
 C$="&kurrent" + CHR(95) + "airbill=" 
 D$="&language=english&cntry" + CHR(95) + "code=us&state=0"
 E$ = A$+B$+C$+B$+D$
 PRINT (0) (LAUNCH=E$)  ! Launch the FedEx tracking page
 RUN "QMONITOR"

We discovered another valuable feature in FedEx's tracking program. The program accepts more than one airbill number. For example, we entered the two airbill numbers (40012892471 and 800667881184) and examined the URL for the results summary page:

 http://www.fedex.com/cgi-bin/track_it?airbills=40012892471%0D%0A800667881184&language=english&state=0&cntry_code=us&Request+Tracking+Info.x=78&Request+Tracking+Info.y=10

Notice the %0D%0A between the two airbill numbers; that's a carriage return/line feed delimiter. Here's the URL for the results detail page for the initial airbill number.

 http://www.fedex.com/cgi-bin/track_it?airbill_list=40012892471}800667881184&kurrent_airbill=40012892471&language=english&cntry_code=us&state=0

We will leave it to the reader to write the MTB code for the multiple airbill examples.

Thanks to Steve Hagen of PDF Systems in New York for suggesting this Comet Tip. As we mentioned in the February 4, 1999 tip, launching web pages from Comet98 is easy, once you know the format of the data string for the CGI program(s). We'll be glad to post other examples like this one. Let us know what you'd like to see.

Personal tools