Various express query-Api Interfaces

Source: Internet
Author: User


Secret Required Authorization KEY. For application, click the express delivery query API application method.
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. 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 "}
<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>
<? 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;?>

Response. Charset = "gb2312"
Server. ScriptTimeout = 999999999

Dim url, nu, com
Com = Request ("com") 'company
Nu = Request ("nu") 'Ticket No.

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

ResponseTxt = fopen (SendURL) '// function for obtaining source code

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

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

Response. Write ResponseTxt
%>

Zhongyou

 


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.