<%@ LANGUAGE = "VBScript" %> <% PilotInitialize trackingnumber = Request.Querystring("tn") If trim("X"&trackingnumber) = "X" Then Response.Write "UPS TrackingSorry, that seems to be an invalid UPS tracking number." Response.End End If Dim XmlHttp, xmlAuth, xmlReq, xmlResp 'Set XmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0") Set XmlHttp = Server.CreateObject("WinHTTP.WinHTTPRequest.5.1") Set xmlAuth = Server.CreateObject("Msxml2.DOMDocument.4.0") Set xmlReq = Server.CreateObject("Msxml2.DOMDocument.4.0") Set xmlResp = Server.CreateObject("Msxml2.DOMDocument.4.0") 'Open connection xmlHTTP.open "POST","https://www.ups.com/ups.app/xml/Track", false 'Access doc xmlAuth.async = false 'Create authentication doc xmlTxt1="" xmlTxt1=xmlTxt1&"" xmlTxt1=xmlTxt1&""&g("UPS_ACCESS_KEY")&"" 'Value from db xmlTxt1=xmlTxt1&""&g("UPS_USERID")&"" 'Value from db xmlTxt1=xmlTxt1&""&g("UPS_PASSWORD")&"" 'Value from db xmlTxt1=xmlTxt1&"" 'Load doc xmlAuth.loadXML(xmlTxt1) 'Create request doc xmlTxt=xmlTxt&"" xmlTxt=xmlTxt&"" xmlTxt=xmlTxt&"" xmlTxt=xmlTxt&"" xmlTxt=xmlTxt&"Tracking" xmlTxt=xmlTxt&"1.0001" xmlTxt=xmlTxt&"" xmlTxt=xmlTxt&"Track" xmlTxt=xmlTxt&"activity" xmlTxt=xmlTxt&"" xmlTxt=xmlTxt&""&trackingnumber&"" xmlTxt=xmlTxt&"" 'Load doc xmlReq.loadXML(xmlTxt) 'Set header fields xml xmlHTTP.setRequestHeader "Content-Type","application/x-www-form-urlencoded" xmlHTTP.setRequestHeader "Content-Length", len(xmlAuth.xml & xmlReq.xml) 'Handle response Dim resp resp = "" On Error Resume Next 'Send request docs xmlHTTP.Send xmlAuth.xml & xmlReq.xml resp = xmlHTTP.responseText If err.number <> 0 Then Response.Write "UPS TrackingSorry, an error has occurred connecting to the UPS server." & _ "" & _ "" & _ "
"&UPSTradeMark("../")&""&UPSTrackingNotice&"
"&UPSTradeMarkNotice&"
" Set xmlAuth = Nothing Set xmlReq = Nothing Set xmlResp = Nothing Set xmlHttp = Nothing Response.End End If If trim("X"&resp) <> "X" Then xmlResp.validateOnParse = False xmlResp.loadXML (resp) 'Response Set ErrorNode = xmlResp.getElementsByTagName("ResponseStatusCode") If ErrorNode.Item(0).text = "0" Then If err.number <> 0 Then Response.Write "UPS TrackingSorry, there is a problem connecting to the UPS server." & _ "" & _ "" & _ "
"&UPSTradeMark("../")&""&UPSTrackingNotice&"
"&UPSTradeMarkNotice&"
" Set xmlAuth = Nothing Set xmlReq = Nothing Set xmlResp = Nothing Set xmlHttp = Nothing Response.End End If 'Trap for these errors '150022 Hard Invalid tracking number. Value does not meet UPS validation rules. '151018 Hard Invalid Tracking Number. Values does not meet UPS validation Rules '151019 Hard No activity records found for tracking number. Activity data related to the ' tracking number is not in database '151044 Hard No Tracking Info Available. Not found in database '151045 Hard No information found. Not found in database '151062 Hard No Tracking Info Available. Not found in database '154030 Hard No information for this tracking number. Missing essential data '154040 Hard Invalid tracking type. Not found in database Set ErrorSeverity = xmlResp.getElementsByTagName("Error") Set er = ErrorSeverity.Item(0) Select Case er.childNodes.Item(1).text Case "151019", "151044", "151045", "151062", "154030" Response.Write "UPS TrackingNo information can be found for that tracking number at this time. Please try again later." & _ "" & _ "" & _ "
"&UPSTradeMark("../")&""&UPSTrackingNotice&"
"&UPSTradeMarkNotice&"
" Set xmlAuth = Nothing Set xmlReq = Nothing Set xmlResp = Nothing Set xmlHttp = Nothing Response.End Case "150022", "151018", "154040" Response.Write "UPS TrackingSorry, that doesn't seem to be a valid UPS tracking number. Please verify the number." & _ "" & _ "" & _ "
"&UPSTradeMark("../")&""&UPSTrackingNotice&"
"&UPSTradeMarkNotice&"
" Set xmlAuth = Nothing Set xmlReq = Nothing Set xmlResp = Nothing Set xmlHttp = Nothing Response.End Case Else Response.Write "UPS TrackingSorry, there is a problem connecting to the UPS server." Set xmlAuth = Nothing Set xmlReq = Nothing Set xmlResp = Nothing Set xmlHttp = Nothing Response.End End Select Else 'No error strColor = "#ffffff" iColor = 0 strHTML="UPS Tracking
" strHTML=strHTML&"" strHTML=strHTML&"" strHTML=strHTML&"" strHTML=strHTML&"" Response.Write "" Response.write "
Recorded activity for UPS tracking number " strHTML=strHTML&trackingnumber&":
" Response.Write strHTML strHTML = "" Set Packages = xmlResp.getElementsByTagName("Package") For l = 0 To Packages.length - 1 strHTML="" strHTML=strHTML&"" strHTML=strHTML&"" strHTML=strHTML&"" strHTML=strHTML&"" strHTML=strHTML&"" Response.Write strHTML strHTML = "" Set m = Packages.Item(l) For z = 0 To m.childNodes.length - 1 Set r = m.childNodes.Item(z) If r.nodename = "Activity" Then For j = 0 To r.childNodes.length - 1 Set e = r.childNodes.Item(j) If e.nodeName = "Date" Then 'What day? strDate = e.text strYear = Mid(strDate, 1, 4) strMonth = Mid(strDate, 5, 2) strDay = Mid(strDate, 7, 2) strd = strMonth&"/"&strDay&"/"&strYear strd = FormatDateTime(strd, 0) Else strDate = "" strYear = "" strMonth = "" strDay = "" 'strd = "" End If 'Date if If e.nodeName = "Time" Then 'What time? strt = "" strTime = e.text strHour = Mid(strTime, 1, 2) strMin = Mid(strTime, 3, 2) strSec = Mid(strTime, 5, 2) strt = strHour&":"&strMin&":"&strSec strt = FormatDateTime(strt, 3) Else strTime = "" strHour = "" strMin = "" strSec = "" 'strt = "" End If 'Time if If e.nodeName = "Status" Then 'What happened? strStatus = "" For k = 0 To e.childNodes.length - 1 Set f = e.childNodes.Item(k) If f.nodename = "StatusType" Then For v = 0 To f.childNodes.length - 1 Set s = f.childNodes.Item(v) If s.nodename = "Description" Then strStatus = f.childNodes.Item(v).text End If 'Description if Next 'StatusType childnodes for End If 'StatusType if Next 'Status childnodes for End If 'Status if If e.nodeName = "ActivityLocation" Then 'Where is it? For k = 0 To e.childNodes.length - 1 Set f = e.childNodes.Item(k) If f.nodename = "Address" Then strCity = "" strState = "" strCountry = "" For t = 0 To f.childNodes.length - 1 Set u = f.childNodes.Item(t) Select Case u.nodename Case "City" strCity = f.childNodes.Item(t).text Case "StateProvinceCode" strState = f.childNodes.Item(t).text Case "CountryCode" strCountry = f.childNodes.Item(t).text End Select Next 'Address childnodes for End If 'Address if Next 'ActivityLocation childnodes for End If 'ActivityLocation if Next ' Activity childnodes for iColor = iColor + 1 If iColor Mod 2 = 0 Then strColor = g("ALT_COLOR2") Else strColor = "ffffff" End If strHTMLend="" strHTMLend=strHTMLend&"" strd = "" strHTMLend=strHTMLend&"" strt = "" strHTMLend=strHTMLend&"" strHTMLend=strHTMLend&"" strHTMLend=strHTMLend&"" Response.Write strHTMLend End If 'Activity if Next 'Package childnodes for Response.Write "
DateTimeLocationActivity
"&strd&""&strt&""&strCity&", "&strState&", "&strCountry&""&strStatus&"
" Next 'Package for End If 'Error if Response.Write"
" & _ "" & _ "
"&UPSTradeMark("")&""&UPSTrackingNotice&"
"&UPSTradeMarkNotice&"
" Else Response.Write "Sorry, there has been an error connecting to the UPS servers." End If Set xmlAuth = Nothing Set xmlReq = Nothing Set xmlResp = Nothing Set xmlHttp = Nothing On Error Goto 0 %>