Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

PHP Extension Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Bitfinex v2 REST
Bluzone
BrickLink
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun
Mastercard

MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter API v2
Twitter v1
UniPin
VoiceBase
Vonage
Walmart
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yousign
ZATCA
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(PHP Extension) Shippo Adding Metadata

Demonstrates how to add metadata to the tracking request through a POST request.

For more information, see https://goshippo.com/docs/tracking/

Chilkat PHP Downloads

PHP Extension for Windows, Linux, MAC OS X,
Alpine Linux, Solaris, OpenBSD, FreeBSD,
and Linux armhf/aarch64

<?php

// The version number (9_5_0) should match version of the Chilkat extension used, omitting the micro-version number.
// For example, if using Chilkat v9.5.0.48, then include as shown here:
include("chilkat_9_5_0.php");

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

$http = new CkHttp();

// 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"

$req = new CkHttpRequest();
$req->put_HttpVerb('POST');
$req->put_Path('/tracks/');
$req->put_ContentType('application/x-www-form-urlencoded');
$req->AddParam('carrier','shippo');
$req->AddParam('tracking_number','SHIPPO_TRANSIT');
$req->AddParam('metadata','Order 000123');

$req->AddHeader('Authorization','ShippoToken <API_TOKEN>');

// resp is a CkHttpResponse
$resp = $http->PostUrlEncoded('https://api.goshippo.com/tracks/',$req);
if ($http->get_LastMethodSuccess() == false) {
    print $http->lastErrorText() . "\n";
    exit;
}

$sbResponseBody = new CkStringBuilder();
$resp->GetBodySb($sbResponseBody);
$jResp = new CkJsonObject();
$jResp->LoadSb($sbResponseBody);
$jResp->put_EmitCompact(false);

print 'Response Body:' . "\n";
print $jResp->emit() . "\n";

$respStatusCode = $resp->get_StatusCode();
print 'Response Status Code = ' . $respStatusCode . "\n";
if ($respStatusCode >= 400) {
    print 'Response Header:' . "\n";
    print $resp->header() . "\n";
    print 'Failed.' . "\n";

    exit;
}

// 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

$carrier = $jResp->stringOf('carrier');
$tracking_number = $jResp->stringOf('tracking_number');
$address_fromCity = $jResp->stringOf('address_from.city');
$address_fromState = $jResp->stringOf('address_from.state');
$address_fromZip = $jResp->stringOf('address_from.zip');
$address_fromCountry = $jResp->stringOf('address_from.country');
$address_toCity = $jResp->stringOf('address_to.city');
$address_toState = $jResp->stringOf('address_to.state');
$address_toZip = $jResp->stringOf('address_to.zip');
$address_toCountry = $jResp->stringOf('address_to.country');
$eta = $jResp->stringOf('eta');
$original_eta = $jResp->stringOf('original_eta');
$servicelevelToken = $jResp->stringOf('servicelevel.token');
$servicelevelName = $jResp->stringOf('servicelevel.name');
$metadata = $jResp->stringOf('metadata');
$tracking_statusObject_created = $jResp->stringOf('tracking_status.object_created');
$tracking_statusObject_updated = $jResp->stringOf('tracking_status.object_updated');
$tracking_statusObject_id = $jResp->stringOf('tracking_status.object_id');
$tracking_statusStatus = $jResp->stringOf('tracking_status.status');
$tracking_statusStatus_details = $jResp->stringOf('tracking_status.status_details');
$tracking_statusStatus_date = $jResp->stringOf('tracking_status.status_date');
$tracking_statusSubstatus = $jResp->stringOf('tracking_status.substatus');
$tracking_statusLocationCity = $jResp->stringOf('tracking_status.location.city');
$tracking_statusLocationState = $jResp->stringOf('tracking_status.location.state');
$tracking_statusLocationZip = $jResp->stringOf('tracking_status.location.zip');
$tracking_statusLocationCountry = $jResp->stringOf('tracking_status.location.country');
$transaction = $jResp->stringOf('transaction');
$test = $jResp->BoolOf('test');
$i = 0;
$count_i = $jResp->SizeOfArray('messages');
while ($i < $count_i) {
    $jResp->put_I($i);
    $i = $i + 1;
}

$i = 0;
$count_i = $jResp->SizeOfArray('tracking_history');
while ($i < $count_i) {
    $jResp->put_I($i);
    $object_created = $jResp->stringOf('tracking_history[i].object_created');
    $object_updated = $jResp->stringOf('tracking_history[i].object_updated');
    $object_id = $jResp->stringOf('tracking_history[i].object_id');
    $status = $jResp->stringOf('tracking_history[i].status');
    $status_details = $jResp->stringOf('tracking_history[i].status_details');
    $status_date = $jResp->stringOf('tracking_history[i].status_date');
    $substatus = $jResp->stringOf('tracking_history[i].substatus');
    $locationCity = $jResp->stringOf('tracking_history[i].location.city');
    $locationState = $jResp->stringOf('tracking_history[i].location.state');
    $locationZip = $jResp->stringOf('tracking_history[i].location.zip');
    $locationCountry = $jResp->stringOf('tracking_history[i].location.country');
    $i = $i + 1;
}


?>

 

© 2000-2022 Chilkat Software, Inc. All Rights Reserved.