Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Visual FoxPro) Shippo Adding MetadataDemonstrates how to add metadata to the tracking request through a POST request. For more information, see https://goshippo.com/docs/tracking/
LOCAL loHttp LOCAL lnSuccess LOCAL loReq LOCAL loResp LOCAL loSbResponseBody LOCAL loJResp LOCAL lnRespStatusCode LOCAL lcObject_created LOCAL lcObject_updated LOCAL lcObject_id LOCAL lcStatus LOCAL lcStatus_details LOCAL lcStatus_date LOCAL lcSubstatus LOCAL lcLocationCity LOCAL lcLocationState LOCAL lcLocationZip LOCAL lcLocationCountry LOCAL lcCarrier LOCAL lcTracking_number LOCAL lcAddress_fromCity LOCAL lcAddress_fromState LOCAL lcAddress_fromZip LOCAL lcAddress_fromCountry LOCAL lcAddress_toCity LOCAL lcAddress_toState LOCAL lcAddress_toZip LOCAL lcAddress_toCountry LOCAL lcEta LOCAL lcOriginal_eta LOCAL lcServicelevelToken LOCAL lcServicelevelName LOCAL lcMetadata LOCAL lcTracking_statusObject_created LOCAL lcTracking_statusObject_updated LOCAL lcTracking_statusObject_id LOCAL lcTracking_statusStatus LOCAL lcTracking_statusStatus_details LOCAL lcTracking_statusStatus_date LOCAL lcTracking_statusSubstatus LOCAL lcTracking_statusLocationCity LOCAL lcTracking_statusLocationState LOCAL lcTracking_statusLocationZip LOCAL lcTracking_statusLocationCountry LOCAL lcTransaction LOCAL lnTest LOCAL i LOCAL lnCount_i * This example assumes the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http') loHttp = CreateObject('Chilkat.Http') * Implements the following CURL command: * curl https://api.goshippo.com/tracks/ \ * -H "Authorization: ShippoToken <API_TOKEN>" \ * -d carrier="shippo" \ * -d tracking_number="SHIPPO_TRANSIT" \ * -d metadata="Order 000123" * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.HttpRequest') loReq = CreateObject('Chilkat.HttpRequest') loReq.HttpVerb = "POST" loReq.Path = "/tracks/" loReq.ContentType = "application/x-www-form-urlencoded" loReq.AddParam("carrier","shippo") loReq.AddParam("tracking_number","SHIPPO_TRANSIT") loReq.AddParam("metadata","Order 000123") loReq.AddHeader("Authorization","ShippoToken <API_TOKEN>") loResp = loHttp.PostUrlEncoded("https://api.goshippo.com/tracks/",loReq) IF (loHttp.LastMethodSuccess = 0) THEN ? loHttp.LastErrorText RELEASE loHttp RELEASE loReq CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbResponseBody = CreateObject('Chilkat.StringBuilder') loResp.GetBodySb(loSbResponseBody) * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJResp = CreateObject('Chilkat.JsonObject') loJResp.LoadSb(loSbResponseBody) loJResp.EmitCompact = 0 ? "Response Body:" ? loJResp.Emit() lnRespStatusCode = loResp.StatusCode ? "Response Status Code = " + STR(lnRespStatusCode) IF (lnRespStatusCode >= 400) THEN ? "Response Header:" ? loResp.Header ? "Failed." RELEASE loResp RELEASE loHttp RELEASE loReq RELEASE loSbResponseBody RELEASE loJResp CANCEL ENDIF RELEASE loResp * Sample JSON response: * (Sample code for parsing the JSON response is shown below) * { * "messages": [ * ], * "carrier": "shippo", * "tracking_number": "SHIPPO_TRANSIT", * "address_from": { * "city": "San Francisco", * "state": "CA", * "zip": "94103", * "country": "US" * }, * "address_to": { * "city": "Chicago", * "state": "IL", * "zip": "60611", * "country": "US" * }, * "eta": "2019-07-07T17:07:44.989Z", * "original_eta": "2019-07-07T17:07:44.989Z", * "servicelevel": { * "token": "shippo_priority", * "name": "Priority Mail" * }, * "metadata": "Shippo test tracking", * "tracking_status": { * "object_created": "2019-07-04T17:07:45.003Z", * "object_updated": null, * "object_id": "ee35fb56f5d04021b36168abedc04573", * "status": "TRANSIT", * "status_details": "Your shipment has departed from the origin.", * "status_date": "2019-07-03T15:02:45.003Z", * "substatus": null, * "location": { * "city": "San Francisco", * "state": "CA", * "zip": "94103", * "country": "US" * } * }, * "tracking_history": [ * { * "object_created": "2019-07-04T17:07:45.005Z", * "object_updated": null, * "object_id": "2121a59f53ed42e0ae0436f636179156", * "status": "UNKNOWN", * "status_details": "The carrier has received the electronic shipment information.", * "status_date": "2019-07-02T12:57:45.005Z", * "substatus": null, * "location": { * "city": "San Francisco", * "state": "CA", * "zip": "94103", * "country": "US" * } * }, * { * "object_created": "2019-07-04T17:07:45.005Z", * "object_updated": null, * "object_id": "06f949db1a8245beaa28df264b368a76", * "status": "TRANSIT", * "status_details": "Your shipment has departed from the origin.", * "status_date": "2019-07-03T15:02:45.005Z", * "substatus": null, * "location": { * "city": "San Francisco", * "state": "CA", * "zip": "94103", * "country": "US" * } * } * ], * "transaction": null, * "test": true * } * Sample code for parsing the JSON response... * Use the following online tool to generate parsing code from sample JSON: * Generate Parsing Code from JSON lcCarrier = loJResp.StringOf("carrier") lcTracking_number = loJResp.StringOf("tracking_number") lcAddress_fromCity = loJResp.StringOf("address_from.city") lcAddress_fromState = loJResp.StringOf("address_from.state") lcAddress_fromZip = loJResp.StringOf("address_from.zip") lcAddress_fromCountry = loJResp.StringOf("address_from.country") lcAddress_toCity = loJResp.StringOf("address_to.city") lcAddress_toState = loJResp.StringOf("address_to.state") lcAddress_toZip = loJResp.StringOf("address_to.zip") lcAddress_toCountry = loJResp.StringOf("address_to.country") lcEta = loJResp.StringOf("eta") lcOriginal_eta = loJResp.StringOf("original_eta") lcServicelevelToken = loJResp.StringOf("servicelevel.token") lcServicelevelName = loJResp.StringOf("servicelevel.name") lcMetadata = loJResp.StringOf("metadata") lcTracking_statusObject_created = loJResp.StringOf("tracking_status.object_created") lcTracking_statusObject_updated = loJResp.StringOf("tracking_status.object_updated") lcTracking_statusObject_id = loJResp.StringOf("tracking_status.object_id") lcTracking_statusStatus = loJResp.StringOf("tracking_status.status") lcTracking_statusStatus_details = loJResp.StringOf("tracking_status.status_details") lcTracking_statusStatus_date = loJResp.StringOf("tracking_status.status_date") lcTracking_statusSubstatus = loJResp.StringOf("tracking_status.substatus") lcTracking_statusLocationCity = loJResp.StringOf("tracking_status.location.city") lcTracking_statusLocationState = loJResp.StringOf("tracking_status.location.state") lcTracking_statusLocationZip = loJResp.StringOf("tracking_status.location.zip") lcTracking_statusLocationCountry = loJResp.StringOf("tracking_status.location.country") lcTransaction = loJResp.StringOf("transaction") lnTest = loJResp.BoolOf("test") i = 0 lnCount_i = loJResp.SizeOfArray("messages") DO WHILE i < lnCount_i loJResp.I = i i = i + 1 ENDDO i = 0 lnCount_i = loJResp.SizeOfArray("tracking_history") DO WHILE i < lnCount_i loJResp.I = i lcObject_created = loJResp.StringOf("tracking_history[i].object_created") lcObject_updated = loJResp.StringOf("tracking_history[i].object_updated") lcObject_id = loJResp.StringOf("tracking_history[i].object_id") lcStatus = loJResp.StringOf("tracking_history[i].status") lcStatus_details = loJResp.StringOf("tracking_history[i].status_details") lcStatus_date = loJResp.StringOf("tracking_history[i].status_date") lcSubstatus = loJResp.StringOf("tracking_history[i].substatus") lcLocationCity = loJResp.StringOf("tracking_history[i].location.city") lcLocationState = loJResp.StringOf("tracking_history[i].location.state") lcLocationZip = loJResp.StringOf("tracking_history[i].location.zip") lcLocationCountry = loJResp.StringOf("tracking_history[i].location.country") i = i + 1 ENDDO RELEASE loHttp RELEASE loReq RELEASE loSbResponseBody RELEASE loJResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.