php express logistics single number query api interface demo address free call

Posted by Earnan on Thu, 19 Sep 2019 12:05:31 +0200

With the flourishing development of online shopping era and express industry, people pay more and more attention to express inquiry service. This article provides you with a good PHP source code development program for API interface of express inquiry, such as four-way one-way express, Shunfeng express, daily express, Yunda express and other hundreds of express and logistics companies. Flow information tracking one-stop query, unlimited, whether individual or enterprise, or e-commerce city, Wechat mall, as long as it involves logistics information tracking query services can be integrated use!
Instructions:
1.kdniao.php doesn't need to change anything
2.example.php is used according to the instructions
3. If there is anything unclear, please consult the official website of Express Bird.
4 docking examples here take express bird as an example.
Demo is written by Express Bird. It can be run by downloading. (Make simple modifications by yourself)
Below is the website to download Demo, according to their own needs to download www.kdniao.com/api-all
[Access process]
Express Bird Logistics Single Number Query api Interface demo Address Free Call
1. Register Express Bird Account on the Registration Page of Express Bird Official Website

2. Login Express Bird User Management Background

Note: User ID and API Key are obtained after login express bird user management background. This is used to ensure the reliability of application source, avoid application forgery and be used illegally.

3. Enter "My Membership Center" for Name Certification
Note:
3.1. Authentication type and application type can be selected according to the user's actual situation. The data returned by the interface has nothing to do with the result of selection.
3.2. The document marked * is required to upload clear, jpg format and less than 2M document pictures.
3.3. The information of technology docking is the information of user docking engineer.
3.4. If you have any other questions, you can join the business cooperation group on the official website for consultation.
After successful certification, enter "product service management" and open related member services.

PHP Express Single Number Query Interface Demo:

<?php
//Electricity supplier ID
defined('EBusinessID') or define('EBusinessID', 'Please apply to express bird website http://kdniao.com/reg');
//E-commerce encryption private key, courier bird provides, take care of, do not leak
defined('AppKey') or define('AppKey', 'Please apply to express bird website http://kdniao.com/reg');
//Request url
defined('ReqURL') or define('ReqURL', 'http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx');
//Invoke and query logistics trajectory
//---------------------------------------------
$logisticResult=getOrderTracesByJson();
echo logisticResult;
//---------------------------------------------
 /**
 * Json Way to Query Order Logistics Trajectory
 */
function getOrderTracesByJson(){
    $requestData= "{'OrderCode':'','ShipperCode':'YTO','LogisticCode':'12345678'}";
        $datas = array(
        'EBusinessID' => EBusinessID,
        'RequestType' => '1002',
        'RequestData' => urlencode($requestData) ,
        'DataType' => '2',
    );
    $datas['DataSign'] = encrypt($requestData, AppKey);
    $result=sendPost(ReqURL, $datas);   
        //Processing the returned information according to the company's business...
        return $result;
}
 /**
 *  post Submit data 
 * @param  string $url Request Url
 * @param  array $datas Data submitted 
 * @return url html returned from the response
 */
function sendPost($url, $datas) {
    $temps = array();   
    foreach ($datas as $key => $value) {
        $temps[] = sprintf('%s=%s', $key, $value);      
    }   
    $post_data = implode('&', $temps);
    $url_info = parse_url($url);
    if(empty($url_info['port']))
    {
        $url_info['port']=80;   
    }
    $httpheader = "POST " . $url_info['path'] . " HTTP/1.0\r\n";
    $httpheader.= "Host:" . $url_info['host'] . "\r\n";
    $httpheader.= "Content-Type:application/x-www-form-urlencoded\r\n";
    $httpheader.= "Content-Length:" . strlen($post_data) . "\r\n";
    $httpheader.= "Connection:close\r\n\r\n";
    $httpheader.= $post_data;
    $fd = fsockopen($url_info['host'], $url_info['port']);
    fwrite($fd, $httpheader);
    $gets = "";
    $headerFlag = true;
    while (!feof($fd)) {
        if (($header = @fgets($fd)) && ($header == "\r\n" || $header == "\n")) {
            break;
        }
    }
    while (!feof($fd)) {
        $gets.= fread($fd, 128);
    }
    fclose($fd);  
        return $gets;
}
/**
 * Sign Signature Generation in E-commerce
 * @param data content   
 * @param appkey Appkey
 * @return DataSign autograph
 */
function encrypt($data, $appkey) {
    return urlencode(base64_encode(md5($data.$appkey)));
}
?>

Topics: PHP less JSON