Various express query-Api interface and express delivery-Api Interface
My key authorized successfully
If you have any reposted information, please indicate the source: http://blog.csdn.net/qxs965268249. please note!
API address:
Previous: 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 descriptionFieldRequired?Description: com must be the courier company code (English). For supported courier companies, see the following list. nu must be the courier order number, and the length must be greater than 5 digits.
Secret required
Id that must be authorized
Authorization KEY. For application, click "express delivery query API Request Method type". Optional return result types, values: html | json (default) | text | xmlencode optional gbk (default) | utf8ord (optional) asc (default) | desc, returned result sorting lang (optional)EnEnglish results returned. Currently, only some express deliveries (EMS, SF, and DHL) are supported)Note:The json_decode function of PHP must be UTF-8 encoded. If json_decode fails, try UTF8 encoding. Return format:Json| Text | html | xml
Encoding:GBK| UTF8
Example: {"status": "3", "message": "", "errCode": "0", "data": [{"time ": "", "context": "Wang Guang, receiver of the four companies in Zhongshan District, Dalian city, Liaoning province, received the mail" },{ "time": "", "context ": "Dalian city, Liaoning province company income" },{ "time": "", "context": "Dalian city, Liaoning province, Zhongshan District, four companies received" },{ "time ": "", "context": "Zhang jinda, dispatcher of Jingyang company, Changchun City, Jilin Province, calls 15948736487" },{ "time ": "", "context": "Zhang jinda, a member of the customer's colleagues who have received and received the email,"}], "html": "", "mailNo": "7151900624 ", "expTextName": "yuantong Express", "expSpellName": "yuyung", "update": "1362656241", "cache": "186488", "ord ": "ASC"} field descriptionFieldTypeDescription: status of the statusint query result. 0 | 1 | 2 | 3 | 4 | 0 indicates that the query failed. 1 is normal. 2 is being sent. 3 is accepted. 4 is returned. 5 other problems: errCodeint error code, 0 no error, 1 ticket No. does not exist, 2 Verification code error, 3 link query server failed, 4 program internal error, 5 program execution error, 6 courier Ticket No. Format error, 7 courier company error, 10 unknown error messagestring error message dataarray progress htmlstring other HTML, this field does not necessarily have mailNostring Express bill number expSpellNamestring express company English code expTextNamestring express company Chinese name updateint last update time (unix timestamp) cacheint cache time, the difference between the current time and update. Unit: Second ordstring sorting, ASC | DESCphp application example
<Script language = "javascript"> <? Php $ id = 'xxxxxxxxxxxxxxxxxxxx'; // go to http://www.ickd.cn/api/reg.html$$url+'http://api.ickd.cn /? Com = shentong & nv= 588035733628 & id = '. $ id; $ data = file_get_contents ($ url); // echo "var data = '", $ data, "'";?> $ (Function () {var dataObj = <? = $ Data?>; // Convert to json object var html = '<tr>'; html + = '<th> logistics status: </th>'; html + = '<td> '; if (dataObj. status> 0) {html + = '<table width = "520px" cellspacing = "0" cellpadding = "0" border = "0" style = "border-collapse: collapse; border-spacing: 0pt; "> '; html + =' <tr> '; html + =' <td width =" 163 "style =" background-color: # e6f9fa; border: 1px solid # 75c2ef; font-size: 14px; font-weight: bold; height: 20px; text-indent: 15px; "> '; html + = 'time '; html + = '</t D> '; html + =' <td width = "354" style = "background-color: # e6f9fa; border: 1px solid # 75c2ef; font-size: 14px; font-weight: bold; height: 20px; text-indent: 15px; "> '; html + = 'location and tracking progress'; html + =' </td> '; html + = '</tr>'; // output data sub-object variable $. each (dataObj. data, function (idx, item) {html + = '<tr>'; html + = '<td width = "163" style = "border: 1px solid # dddddddd; font-size: 12px; line-height: 22px; padding: 3px 5px; "> '; html + = item. time; // The value Time html + = '</td>'; html + = '<td width = "354" style = "border: 1px solid # dddddddd; font-size: 12px; line-height: 22px; padding: 3px 5px; "> '; html + = item. context; // the status of each piece of data: html + = '</td>'; html + = '</tr> ';}); html + = '</table>';} else {// No html + = '<span style = "color: # f00"> Sorry! '+ DataObj. message + '</span>';} html + = '</td> </tr>'; $ ("# shipping_detail "). append (html) ;}); </script>
If file_get_contents and fsockopen functions are disabled on the server, you can use the CURL class, for example:
<? Php $ id = 'xxxxxxxxxxxxxxxx'; // api key $ com = 'shunfeng'; // courier company $ nu = '000000 '; // Waybill No. $ 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") 'Ticket No.
Dim AppKey, SendURL, ResponseTxt
AppKey = "xxxxxxxxxx" 'replace XXXXXX with the key you applied for at http://www.ickd.cn/reg.html.
SendURL = "http://api.ickd.cn /? Id = "& AppKey &" & com = "& com &" & nu = "& nu &" & type = json & encode = GBK "'If UTF8 is used, make sure that encode = utf8
'Response. Write SendURL
'Send data
ResponseTxt = fopen (SendURL) '// function for obtaining source code
'Call the data sending component
Function fopen (URL)
Dim objXML
'Set objXML = CreateObject ("MSXML2.SERVERXMLHTTP. 3.0") 'calls the XMLHTTP component. If the server does not support this, use one of the following to try again:
Set objXML = Server. CreateObject ("Microsoft. XMLHTTP ")
'Set objXML = Server. CreateObject ("MSXML2.XMLHTTP. 4.0 ")
'Objxml. SetTimeouts 5000,500 0, 30000,100 00' specifies the timeout time for DNS name resolution, the timeout time for establishing a Winsock connection, the timeout time for sending data, and the timeout time for receiving response. 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: 'Data retrieval error '}"
Exit Function
End If
The 'readystate' attribute returns the current information of the XML file. The returned values are as follows:
'0-UNINITIALIZED: XML objects are generated, but no files are loaded.
'1-LOADING: LOADING program in progress, but File Parsing has not started yet.
'2-LOADED: some files have been LOADED and parsed, but the object model has not yet taken effect.
'3-INTERACTIVE: valid only for some loaded files. In this case, the object model is valid but read-only.
'4-COMPLETED: the file is fully loaded, indicating that the file is successfully loaded.
Fopen = objXML. ResponseBody
Fopen = BytesToBstr (objXML. ResponseBody) 'returns information and uses function-defined encoding. If you need to transcode, select
Set objXML = Nothing 'disabled
If Err. number <> 0 Then
Response. Write "{status: 0, errCode: 100, message: 'Data retrieval error '}"
Err. Clear
End If
End Function
'Page encoding conversion
Function BytesToBstr (body)
Dim objstream
Set objstream = Server. CreateObject ("Adodb. Stream") '// call the adodb. stream component.
Objstream. Type = 1
Objstream. Mode = 3
Objstream. Open
Objstream. Write body
Objstream. Position = 0
Objstream. Type = 2
Objstream. Charset = "GBK" 'to convert the original default encoding to GB2312 encoding. Otherwise, the webpage with Chinese characters can be called through XMLHTTP to obtain garbled characters.
BytesToBstr = objstream. ReadText
Objstream. Close
Set objstream = Nothing
End Function
'Enter the query result
Response. Write ResponseTxt
%>