Various Express Query--api interface, express--api interface _php Tutorial

Source: Internet
Author: User

All kinds of express Query--api interface, Express--API interface



Authorize my key for success

If there is reprint, please indicate from this source http://blog.csdn.net/qxs965266509, must pay attention!

Love to check the Express API using the description document API address:

Formerly: http://api.ickd.cn/?com=[]&nu=[]&id=[]&type=[]&encode=[]&ord=[]&lang=[]

Current: http://api.ickd.cn/?id=[]&secret=[]&com=[]&nu=[]&type=[]&encode=[]&ord=[]&lang= []

Parameter descriptionFieldWhether you mustDescription COM must express the company code (in English), supported by The courier company see the following list Nu must express the number, the length must be greater than 5 bit ID
Secret must
ID that must be authorized
Authorization key, please click the Express Query API application method type optional return result type, value is HTML | JSON (default) | Text | Xmlencode Optional GBK (default) | Utf8ord optional ASC (default) |desc, returns the result sort lang optionalenBack to English results, currently only support partial Express (EMS, Shun Fung, DHL)Note:You must use UTF8 encoding when using PHP's Json_decode function, and if Json_decode fails, try using UTF8 encoding. Return format format:JSON| Text | HTML | Xml
Coding:GBK| UTF8
Example: {"Status": "3", "Message": "", "Errcode": "0", "data": [{"Time": "2013-02-23 17:10", "context": "The recipient of four Department of Zhongshan district, Dalian City, Liaoning province Wang Guang Received "},{" Time ":" 2013-02-24 17:59 "," context ":" Liaoning Province Dalian Company has revenue "},{" Time ":" 2013-02-24 18:11 "," context ":" Four Zhongshan District, Dalian City, Liaoning Province, the company has received "},{" Time ":" 2013-02-26 07:33 "," context ":" Changchun City, Jilin Province, King Yang Company's dispatch member Acupuncturists sent a piece of the phone 15948736487 "},{" Time ":" 2013-02-26 16:47 "," Context ":" The customer colleagues send and receive the family has signed the recipient Acupuncturists "}]," HTML ":" "," Mailno ":" 7151900624 "," Exptextname ":" Yuantong Express "," Expspellname ":" Yuantong ", "Update": "1362656241", "Cache": "186488", "Ord": "ASC"} Field DescriptionFieldTypeDescription Statusint Query result status, 0|1|2|3|4,0 indicates that the query failed, 1 normal, 2 delivery, 3 signed, 4 returned, 5 other problems errcodeint error code, 0 no error, 1 number does not exist, 2 captcha error, 3 link query server failed, 4 Program Internal error, 5 program execution error, 6 Express number format error, 7 Courier company Error, 10 unknown error messagestring error message DataArray Progress htmlstring other HTML, This field does not necessarily exist mailnostring Express number expspellnamestring Express Company English Code exptextnamestring courier company Chinese name Updateint last updated time (Unix timestamp) Cacheint cache time , the difference between the current time and update, in seconds ordstring sort, ASC | descphp Application Examples

If the server disables functions such as file_get_contents and Fsockopen, you can use the Curl class, as shown in the following example:

<?php $id = ' xxxxxxxxxxxxx ';//api KEY $com = ' Shunfeng ';//Express Company $nu = ' 123456 ';//Express ticket $type = ' json '; $encode = ' UTF8 '; $gateway =sprintf (' http://api.ickd.cn/?id=%s&com=%s&nu=%s&encode=%s&type=%s ', $id, $com, $nu, $ Encode, $type); $ch =curl_init ($gateway); curl_setopt ($ch, curlopt_returntransfer,true); curl_setopt ($ch, Curlopt_header,false); $resp =curl_exec ($ch); $errmsg =curl_error ($ch); if ($errmsg) {exit ($errmsg);} curl_close ($ch); Echo $resp;? >

ASP Application Example

<%
response.charset= "gb2312"
Server.ScriptTimeout = 999999999

Dim Retrieval
Dim url,nu,com
com = Request ("com") ' Company
Nu = Request ("nu") ' Waybill number

Dim Appkey,sendurl,responsetxt
AppKey = "xxxxxxxxxx" ' please replace xxxxxx with the key you requested in the http://www.ickd.cn/reg.html
Sendurl = "http://api.ickd.cn/?id=" &AppKey& "&com=" &com& "&nu=" &nu& "&type=json &ENCODE=GBK "' If you use UTF8, make sure Encode=utf8
' Response.Write Sendurl

' Send data
Responsetxt=fopen (Sendurl) '//function to get source code

' Invoke Send data component
Function fopen (URL)
Dim Objxml
' Set objxml=createobject ("MSXML2. serverxmlhttp.3.0 ") ' Call the XMLHTTP component, if the server does not support, please change the following two one retry
Set objxml=server.createobject ("Microsoft.XMLHTTP")
' Set objxml=server.createobject ("MSXML2. xmlhttp.4.0 ")

' Objxml.settimeouts 5000, 5000, 30000, 10000 ' resolves the DNS name timeout, establishes a Winsock connection timeout, sends the data timeout, and receives the response time-out. Unit milliseconds
Objxml.open "Get", Url,false ' Get API query data synchronously
Objxml.send () ' Send
If objxml.readystate<>4 Then ' status is not 4, error
Response.Write ' {status:0,errcode:100,message: ' Get data error '} '
Exit Function
End If
' ReadyState property, returns the current state of the XML file data, with the following values, respectively:
The ' 0-uninitialized:xml object was generated, but no files were loaded.
' 1-loading: The loader is in progress, but the file has not started parsing.
' 2-loaded: Some of the files have been loaded and parsed, but the object model has not yet taken effect.
' 3-interactive: Only valid for partially loaded files, in which case the object model is valid but read-only.
' 4-completed: The file has been fully loaded and represents a successful load.

Fopen=objxml.responsebody
Fopen=bytestobstr (objxml.responsebody) ' returns information, with function definition encoding, if you need to transcode, select

Set objxml=nothing ' off
If Err.number<>0 Then
Response.Write ' {status:0,errcode:100,message: ' Get data error '} '
Err.Clear
End If
End Function

' Page encoding Conversion
Function Bytestobstr (body)
Dim objstream
Set objstream = Server.CreateObject ("ADODB.stream") '//Call ADODB.stream component
Objstream. Type = 1
Objstream. Mode =3
Objstream. Open
Objstream. Write body
Objstream. Position = 0
Objstream. Type = 2
Objstream. Charset = "GBK" ' conversion of the original default encoding converted to GB2312 encoding, or directly with the XMLHTTP call with Chinese characters will be garbled
Bytestobstr = objstream. ReadText
Objstream. Close
Set objstream = Nothing
End Function

' Enter query results
Response.Write Responsetxt
%>

http://www.bkjia.com/PHPjc/1123833.html www.bkjia.com true http://www.bkjia.com/PHPjc/1123833.html techarticle all kinds of express Query--api interface, express--API interface Authorization successful my key if reproduced, please indicate from this source http://blog.csdn.net/qxs965266509, must pay attention! Love Check Express AP ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.