TrackingMore Webhooks

Webhook 

Webhook URL
Learn more about   format of inbound webhooks
Version
Callback
If selecting "true", then there must return a "200" response!

Che cosa è Webhook?

     Webhook è un modo per cambiare le applicazioni web attraverso la personalizzazione di funzioni di callback. Via Webhook, è possibile selezionare gli Stati che si desidera essere avvisati e ricevi le notifiche tramite l'URL specificato. Durante il completamento dei dati richiedente, Webhook risponderà i dati a voi attraverso il vostro URL configurato.

 Webhook V2

     When the tracking is updated and it triggers an update of one of your trigger setting, we make a POST request to the callback URL that you defined in the webhook page. The post body contains a JSON string of the below data.

     We currently support either HTTP or HTTPS urls, so you can have security by using an SSL-enabled url. But keep in mind that your endpoint is going to be wide-open on the internet.

     Signature Verification:

     You can verify safely about the source of POST data to make sure it is from Trackingmore. You can also analyze the POST data directly without verification. Below are steps about safety verification.

     1. Analyze the two parameters ("timeStr" and "signature") in the POST data.

     2. Use your registered email address(secret key) on Trackingmore and the parameter "timeStr(proclaim in writing)" to generate "signature", and then verify the generated "signature" with the signature from POST data. Note: Signature Algorithm is PHP:SHA256、JAVA:HmacSHA256.

     PHP Example Code:
function verify($timeStr,$useremail,$signature){
    $hash="sha256";
    $result=hash_hmac($hash,$timeStr,$useremail);
    return strcmp($result,$signature)==0?1:0;
}

     How to use:

       Step 1:Go my.trackingmore.com/webhook_setting.php to set your webhook url and statuses that you want to be notified.

       Step 2:When the system detects that the statuses of tracking numbers change into the statuses you set, then your configured webhook url will receive the updated data. To achieve this function, you need to program this webhook url first.

       Step 3:To get data from webhook, you only need $inputJSON = file_get_contents("php://input") in php and $inputJSON is the data we pushed. Below are examples on how we get data and write it into a file. You can also store them into the database.


  •   Example Code  
  • Write response data into file
    
    $handle    = fopen('test.log','a+'); 
    $inputJSON = file_get_contents("php://input");
    if(!empty($inputJSON)){
    	fwrite($handle, date("Y-m-d H:i:s").":  ".$inputJSON . "\r\n");
    	echo 200;
    }else{
    	fwrite($handle, date("Y-m-d H:i:s").": can not get webhook data!\r\n");
    }
    
  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {
    "meta":{
       "code":200,
       "type":"Success",
       "message":"Success"
    },
    "data":{
    	"id":"7eabcb811fa10ab1f77d10418579a7f5",
    	"tracking_number":"LX203960974CN",
    	"carrier_code":"china-ems",
    	"status":"exception",
    	"created_at":"2016-11-09T22:21:43+08:00",
    	"updated_at":"2016-11-16T00:13:34+08:00",
    	"title":"","order_id":null,
    	"customer_name":null,
    	"customer_email":"",
    	"original_country":"China",
    	"destination_country":"Sweden",
    	"itemTimeLength":18,
    	"origin_info":{
    		"weblink":"http:\/\/www.ems.com.cn\/",
    		"phone":null,
    		"carrier_code":"china-ems",
    		"trackinfo":[
    		{
    			"Date":"2016-11-15 08:23",
    			"StatusDescription":"\u672a\u59a5\u6295",
    			"Details":"\u745e\u5178"
    		},{
    			"Date":"2016-11-14 09:34",
    			"StatusDescription":"\u5230\u8fbe\u5904\u7406\u4e2d\u5fc3,\u6765\u81ea\u4e2d\u56fd \u5e7f\u5dde",
    			"Details":"\u745e\u5178"
    		},{
    			"Date":"2016-10-31 22:45",
    			"StatusDescription":"\u6d77\u5173\u653e\u884c",
    			"Details":"\u5e7f\u5dde\u5e02"
    		},{
    			"Date":"2016-10-31 22:35",
    			"StatusDescription":"\u9001\u4ea4\u6d77\u5173",
    			"Details":"\u5e7f\u5dde\u5e02"
    		},{
    			"Date":"2016-10-29 22:04",
    			"StatusDescription":"\u5230\u8fbe\u5e7f\u5dde\u822a\u7ad9\u5904\u7406\u4e2d\u5fc3\uff08\u7ecf\u8f6c\uff09",
    			"Details":"\u5e7f\u5dde\u5e02"
    		},{
    			"Date":"2016-10-29 20:20",
    			"StatusDescription":"\u79bb\u5f00\u4e2d\u5c71\u5e02 \u53d1\u5f80\u5e7f\u5dde\u5e02",
    			"Details":"\u4e2d\u5c71\u5e02"
    		},{
    			"Date":"2016-10-29 16:24",
    			"StatusDescription":"\u4e2d\u5c71\u5e02\u90ae\u653f\u901f\u9012\u7269\u6d41\u516c\u53f8\u6052\u57fa\u901f\u9012\u90e8\u5df2\u6536\u4ef6\uff08\u63fd\u6295\u5458\u59d3\u540d\uff1a\u9ad8\u4f1f\u5065,\u8054\u7cfb\u7535\u8bdd:13631122287\uff09",
    			"Details":"\u4e2d\u5c71\u5e02"
    		}]
    	},
    	"destination_info":{
    		"weblink":"http:\/\/www.posten.se\/",
    		"phone":null,
    		"carrier_code":"sweden-posten",
    		"trackinfo":[{
    			"Date":"2016-11-15 15:04",
    			"StatusDescription":"Posten has not been able to reach the recipient for delivery before 10.00. New delivery attempt to be made no later than 18.00. The item will subsequently be treated as an ordinary letter",
    			"Details":"535031, Sweden"
    		},{
    			"Date":"2016-11-15 14:00",
    			"StatusDescription":"The shipment item could not be delivered because the recipient was not possible to reach. A notice has been given and the shipment item is delivered to a service point.",
    			"Details":"535031, Sweden"
    		},{
    			"Date":"2016-11-15 07:23",
    			"StatusDescription":"The item has arrived at the recipient\u00b4s delivery point. Express to be dispatched to the recipient, other items notified",
    			"Details":"535031, Sweden"
    		},{
    			"Date":"2016-11-14 23:32",
    			"StatusDescription":"The item has been through the post terminal",
    			"Details":"149, Sweden"
    		},{
    			"Date":"2016-11-14 09:34",
    			"StatusDescription":"The item has arrived from abroad to Posten\u00b4s international terminal for sorting",
    			"Details":"Stockholm utr"
    		}]
    	},
    	"lastEvent":"\u672a\u59a5\u6295,\u745e\u5178,2016-11-15 08:23"
    },
    "verifyInfo":{
      "timeStr":1488249109,
      "signature":"4b279021f5c041f6e3344e7a0636cc26201ab24b91adcea6d38331cb89221d45"
    }
    }
    

Porta la tua esperienza di tracciamento degli ordini post-acquisto alla classe successiva