最新消息:觉得本站不错的话 记得收藏哦 博客内某些功能仅供测试 讨论群:135931704 快养不起小站了 各位有闲钱就打赏下把 My Email weicots#gmail.com Please replace # with @

本站提供USPS 和DHL 等快递查询接口

FEE ajiang-tuzi 6414浏览
本文会持续更新 请关注本文

关于 USPS
美国邮政署(英语:United States Postal Service, USPS),亦称美国邮局或美国邮政服务,是美国联邦政府的独立机构。美国邮政署拥有596,000名雇员,以及218,684辆汽车,是全球最庞大的民用车队。每年处理177亿信件,占全球数量的四成。美国邮政署是少数在美国宪法中提及设立的机构。
公司名称 美国邮政署
外文名称 United States Postal Service
总部地点美国
成立时间 1775年7月26日
经营范围 信件,包裹,快递
公司性质 国家政府机构
员工数 596,000名
汽车数 218,684辆
备注
usps的E开头的到国内的是转EMS
usps的L,R,C开头的到过内是转中国邮政,级别要低不少的。
其中L的级别是最低的,L开头的和中国邮政的平邮包裹性质差不多
效验地址 usps 183网站查询
接口地址 目前只支持 DHL USPS

‘http://www.weicot.com/api.php?

完整地址

//地址 ‘http://www.weicot.com/api.php?com='$typeCom.'&no='.$typeNu.'&user='.$user.'&type='.$type;
http://www.weicot.com/api.php?com=[快递公司简写 USPS/DHL]&no=[快递单号]&user=[用户账号/10086]&type=[返回类型/xml/jsom/all]

接口格式
com 快递公司
no 快递号
user 使用账号号 [ XXXX ] 免费帐号无次数限制
type 类型
支持的返回格式

usps 支持 xml json all
DHL  支持 json all
备注:all 是以
 为分隔符

USPS接口示范
XML

http://www.weicot.com/api.php?com=usps&no=LS26xxxxxx5CN&user=11211&type=xml
<?xml version="1.0" encoding="UTF-8"?>
<TrackResponse><TrackInfo ID="LS26xxxxx835CN">
<TrackSummary>Your item was delivered to the front desk or reception area at 12:35 pm on November 25, 2015 in OLYMPIA, WA 98516.</TrackSummary>
<TrackDetail>Out for Delivery, November 25, 2015, 6:56 am, OLYMPIA, WA 98516</TrackDetail>
<TrackDetail>Sorting Complete, November 25, 2015, 6:46 am, OLYMPIA, WA 98516</TrackDetail>
<TrackDetail>Arrived at Unit, November 25, 2015, 4:30 am, LACEY, WA 98503</TrackDetail>
<TrackDetail>Departed USPS Facility, November 25, 2015, 1:23 am, FEDERAL WAY, WA 98003</TrackDetail>
<TrackDetail>Arrived at USPS Destination Facility, November 24, 2015, 8:46 pm, FEDERAL WAY, WA 98003</TrackDetail>
<TrackDetail>Departed USPS Facility, November 22, 2015, 11:24 pm, SAN FRANCISCO, CA 94128</TrackDetail>
<TrackDetail>Arrived at USPS Facility, November 22, 2015, 9:02 am, SAN FRANCISCO, CA 94128</TrackDetail>
<TrackDetail>Processed Through Sort Facility, November 22, 2015, 7:53 am, ISC SAN FRANCISCO (USPS)</TrackDetail>
<TrackDetail>Processed Through Sort Facility, November 19, 2015, 6:11 pm, FUZHOU EMS, CHINA</TrackDetail>
<TrackDetail>Origin Post is Preparing Shipment</TrackDetail><TrackDetail>Acceptance, November 18, 2015, 8:56 pm, CHINA</TrackDetail>
</TrackInfo>
</TrackResponse>

JSON

http://www.weicot.com/api.php?com=usps&no=LS26xxxxx5CN&user=11211&type=json
{"TrackResponse":{"TrackInfo":
{"TrackSummary":"Your item was delivered to the front desk or reception area at 12:35 pm on November 25, 2015 in OLYMPIA, WA 98516.","
TrackDetail":["Out for Delivery, November 25, 2015, 6:56 am, OLYMPIA, WA 98516",
"Sorting Complete, November 25, 2015, 6:46 am, OLYMPIA, WA 98516","Arrived at Unit, November 25, 2015, 4:30 am, LACEY, WA 98503",
"Departed USPS Facility, November 25, 2015, 1:23 am, FEDERAL WAY, WA 98003","Arrived at USPS Destination Facility, November 24, 2015, 8:46 pm, FEDERAL WAY, WA 98003","Departed USPS Facility, November 22, 2015, 11:24 pm, SAN FRANCISCO, CA 94128","Arrived at USPS Facility, November 22, 2015, 9:02 am, SAN FRANCISCO, CA 94128","Processed Through Sort Facility, November 22, 2015, 7:53 am, ISC SAN FRANCISCO (USPS)","Processed Through Sort Facility, November 19, 2015, 6:11 pm, FUZHOU EMS, CHINA","Origin Post is Preparing Shipment","Acceptance, November 18, 2015, 8:56 pm, CHINA"]}}}

ALL

Out for Delivery, November 25, 2015, 6:56 am, OLYMPIA, WA 98516
Sorting Complete, November 25, 2015, 6:46 am, OLYMPIA, WA 98516
Arrived at Unit, November 25, 2015, 4:30 am, LACEY, WA 98503
Departed USPS Facility, November 25, 2015, 1:23 am, FEDERAL WAY, WA 98003
Arrived at USPS Destination Facility, November 24, 2015, 8:46 pm, FEDERAL WAY, WA 98003
Departed USPS Facility, November 22, 2015, 11:24 pm, SAN FRANCISCO, CA 94128
Arrived at USPS Facility, November 22, 2015, 9:02 am, SAN FRANCISCO, CA 94128
Processed Through Sort Facility, November 22, 2015, 7:53 am, ISC SAN FRANCISCO (USPS)
Processed Through Sort Facility, November 19, 2015, 6:11 pm, FUZHOU EMS, CHINA
Origin Post is Preparing Shipment
Acceptance, November 18, 2015, 8:56 pm, CHINA

DHL 支持 json all 用法跟 USPS 一样
DHL JSON

http://www.weicot.com/api.php?com=DHL&no=92xxxxx810&user=10086&type=json
[{"counter":19,"description":"Delivered - Signed for by : EDUARDO ZAVALA","time":"11:15","date":"Friday, December 04, 2015 ","location":"HARLINGEN "},
{"counter":18,"description":"With delivery courier","time":"10:46","date":"Friday, December 04, 2015 ","location":"HARLINGEN, TX - USA","totalPieces":1,"pIds":["JD014600002650900941"]},{"counter":17,"description":"Awaiting collection by recipient as requested","time":"08:39","date":"Friday, December 04, 2015 ","location":"HARLINGEN, TX - USA"},

{"counter":15,"description":"Departed Facility in CINCINNATI HUB - USA","time":"05:41","date":"Friday, December 04, 2015 ","location":"CINCINNATI HUB, OH - USA","totalPieces":1,"pIds":["JD014600002650900941"]},
{"counter":14,"description":"Processed at CINCINNATI HUB - USA","time":"00:21","date":"Friday, December 04, 2015 ","location":"CINCINNATI HUB, OH - USA","totalPieces":1,"pIds":["JD014600002650900941"]},
{"counter":13,"description":"Clearance processing complete at CINCINNATI HUB - USA","time":"23:49","date":"Thursday, December 03, 2015 ","location":"CINCINNATI HUB, OH - USA","totalPieces":1,"pIds":["JD014600002650900941"]},
{"counter":12,"description":"Arrived at Sort Facility CINCINNATI HUB - USA","time":"23:30","date":"Thursday, December 03, 2015 ","location":"CINCINNATI HUB, OH - USA","totalPieces":1,"pIds":["JD014600002650900941"]},
{"counter":11,"description":"Customs status updated","time":"11:21","date":"Thursday, December 03, 2015 ","location":"CINCINNATI HUB, OH - USA"},
{"counter":10,"description":"Departed Facility in HONG KONG - HONG KONG","time":"18:19","date":"Thursday, December 03, 2015 ","location":"HONG KONG - HONG KONG","totalPieces":1,"pIds":["JD014600002650900941"]},

{"counter":9,"description":"Processed at HONG KONG - HONG KONG","time":"17:45","date":"Thursday, December 03, 2015 ","location":"HONG KONG - HONG KONG","totalPieces":1,"pIds":["JD014600002650900941"]},

{"counter":8,"description":"Clearance processing complete at HONG KONG - HONG KONG","time":"05:20","date":"Thursday, December 03, 2015 ","location":"HONG KONG - HONG KONG","totalPieces":1,"pIds":["JD014600002650900941"]},
{"counter":7,"description":"Processed at HONG KONG - HONG KONG","time":"05:20","date":"Thursday, December 03, 2015 ","location":"HONG KONG - HONG KONG","totalPieces":1,"pIds":["JD014600002650900941"]},{"counter":6,"description":"Arrived at Sort Facility HONG KONG - HONG KONG","time":"04:47","date":"Thursday, December 03, 2015 ","location":"HONG KONG - HONG KONG","totalPieces":1,"pIds":["JD014600002650900941"]},{"counter":5,"description":"Customs status updated","time":"01:09","date":"Thursday, December 03, 2015 ","location":"HONG KONG - HONG KONG"},
{"counter":4,"description":"Departed Facility in GUANGZHOU - CHINA, PEOPLES REPUBLIC","time":"23:42","date":"Wednesday, December 02, 2015 ","location":"GUANGZHOU - CHINA, PEOPLES REPUBLIC","totalPieces":1,"pIds":["JD014600002650900941"]},{"counter":3,"description":"Processed at GUANGZHOU - CHINA, PEOPLES REPUBLIC","time":"23:37","date":"Wednesday, December 02, 2015 ","location":"GUANGZHOU - CHINA, PEOPLES REPUBLIC","totalPieces":1,"pIds":["JD014600002650900941"]},----
----------]

ALL 的格式是处理过的 以 <br /> 为分隔符

Delivered - Signed for by : EDUARDO ZAVALA
Friday, December 04, 2015 11:15
HARLINGEN
With delivery courier
Friday, December 04, 2015 10:46
HARLINGEN, TX - USA
Awaiting collection by recipient as requested
Friday, December 04, 2015 08:39
HARLINGEN, TX - USA
Arrived at Delivery Facility in HARLINGEN - USA
Friday, December 04, 2015 08:29
HARLINGEN, TX - USA
Departed Facility in CINCINNATI HUB - USA
Friday, December 04, 2015 05:41
CINCINNATI HUB, OH - USA
Processed at CINCINNATI HUB - USA
Friday, December 04, 2015 00:21
CINCINNATI HUB, OH - USA
Clearance processing complete at CINCINNATI HUB - USA
Thursday, December 03, 2015 23:49
CINCINNATI HUB, OH - USA
Arrived at Sort Facility CINCINNATI HUB - USA
Thursday, December 03, 2015 23:30
CINCINNATI HUB, OH - USA
Customs status updated
Thursday, December 03, 2015 11:21
CINCINNATI HUB, OH - USA
---------

新版本代码

<?php
/*
*WeiCot快递API
*20160115  V 0.2.1
*www.weicot.com
*http://www.weicot.com/api.php?
*com=[快递公司简写 USPS/DHL]
*&no=[快递单号]
*&user=[用户账号/10086]
*&type=[返回类型/xml/jsom/all简版/allA优化版/allB第三方版]
*/
class Aps_Weicot_Model_getTrack{
    public $ApiUrl="http://www.weicot.com/api.php?com=";
    public $key="XXXXXX";//用户账号 
    function curl ($url){
        if (function_exists('curl_init') == 1){
            $curl = curl_init();
            curl_setopt ($curl, CURLOPT_URL, $url);
            curl_setopt ($curl, CURLOPT_HEADER,0);
            curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt ($curl, CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);
            curl_setopt ($curl, CURLOPT_TIMEOUT,5);
            $get_content = curl_exec($curl);
            curl_close ($curl);
            return $get_content;
        }
    }
     
    public function DHLAPI($typeNu){
        $typeNu=trim($typeNu," ");
        $getUrl=$this->ApiUrl
            ."DHL&no="
            .$typeNu
            ."&user="
            .$this->key
            ."&type=allA";
        echo $this->curl($getUrl);
    }
    public function USPSAPI($typeNu){
        $typeNu=trim($typeNu," ");
        $getUrl=$this->ApiUrl
            ."usps&no="
            .$typeNu
            ."&user="
            .$this->key
            ."&type=allA";
        echo $this->curl($getUrl);
    }
    public function CanadaPos($typeNu){
        $typeNu=trim($typeNu," ");
        $getUrl=$this->ApiUrl
            ."canadapost&no="
            .$typeNu
            ."&user="
            .$this->key
            ."&type=allA";
        echo $this->curl($getUrl);
    }
    public function KDAPI($typeCom,$typeNu){
        $typeNu=trim($typeNu," ");
        $getUrl=$this->ApiUrl
            .trim($typeCom," ")
            ."&no="
            .$typeNu
            ."&user="
            .$this->key
            ."&type=allB";
        echo $this->curl($getUrl);
    }
    public function getKdInfo($typeCom,$typeNu){
        if (strtolower($typeCom)=='dhl'){
            $this->DHLAPI($typeNu);//DHL 官方接口
        }elseif(strtolower($typeCom)=='usps'){
            $this->USPSAPI($typeNu);//USPS 接口
        }elseif(strtolower($typeCom)=='canadapost'){
            $this->CanadaPos($typeNu);
        }else{
            $this->KDAPI($typeCom,$typeNu);//第三方接口
        }
    }
}

//使用方法
$getTrack=new Aps_Weicot_Model_getTrack;
$getTrack->getKdInfo("DHL","xxxxxxx");
?>

转载请注明:(●--●) Hello.My Weicot » 本站提供USPS 和DHL 等快递查询接口