Authorization successful my key
If you reprint, please indicate the source http://blog.csdn.net/qxs965266509, please pay attention!
Aicha Express API instruction document API address:
Previously: http://api.ickd.cn/?com=[]&nu=[]&id=[]&type=[]&encode=[]&ord=[]&lang=[]
Currently: http://api.ickd.cn/?id=[]&secret=[]&com=[]&nu=[]&type=[]&encode=[]&ord=[]&lang=[]
Parameter description
<script language="javascript"> <?php$id='xxxxxxxxxxxxxxxxx'; //到<a href="http://www.ickd.cn/api/reg.html">http://www.ickd.cn/api/reg.html</a>申请 $url='http://api.ickd.cn/?com=shentong&nu=588035733628&id='.$id; $data=file_get_contents($url); //echo "var data='",$data,"'"; ?> $(function(){ var dataObj=<?=$data?>; //转换为json对象 var html='<tr>'; html+='<th>物流状态:</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+='时间'; html+='</td>'; html+='<td width="354" style="background-color:#e6f9fa;border:1px solid #75c2ef;font-size:14px;font-weight:bold;height:20px;text-indent:15px;">'; html+='地点和跟踪进度'; html+='</td>'; html+='</tr>'; //输出data的子对象变量 $.each(dataObj.data,function(idx,item){ html+='<tr>'; html+='<td width="163" style="border:1px solid #dddddd;font-size: 12px;line-height:22px;padding:3px 5px;">'; html+=item.time;// 每条数据的时间 html+='</td>'; html+='<td width="354" style="border:1px solid #dddddd;font-size: 12px;line-height:22px;padding:3px 5px;">'; html+=item.context;// 每条数据的状态 html+='</td>'; html+='</tr>'; }); html+='</table>'; }else{ //查询不到 html+='<span style="color:#f00">Sorry! '+dataObj.message+'</span>'; } html+='</td></tr>'; $("#shipping_detail").append(html);});</script>
If the server has disabled functions such as file_get_contents and fsockopen, you can use the CURL class. The example is as follows:
<?php $id='xxxxxxxxxxxxx'; //API KEY $com='shunfeng'; //快递公司 $nu='123456'; //快递单号 $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")'Order number
Dim AppKey,SendURL,ResponseTxt
AppKey = "xxxxxxxxxx" 'Please 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 using UTF8, please make sure encode=utf8
'Response.Write SendURL
'Send data
ResponseTxt=fopen(SendURL) '//Function to get source code
'Call the 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 it, please use one of the following two and try again
Set objXML=Server.CreateObject("Microsoft.XMLHTTP")
'Set objXML=Server.CreateObject("MSXML2.XMLHTTP.4.0")
'objXML.SetTimeouts 5000, 5000, 30000, 10000' The timeout for resolving DNS names, the timeout for establishing a Winsock connection, the timeout for sending data, and the timeout for receiving responses. Unit millisecond
objXML.Open "GET",URL,False 'Get API query data synchronously
objXML.Send() 'Send
If objXML.Readystate<>4 Then 'The status is not 4, error
Response.Write "{status:0,errCode:100,message:'Error getting data'}"
Exit Function
End If
'Readystate attribute returns the current status of the XML file data. The return values are as follows:
'0-UNINITIALIZED: XML object was generated, but no file was loaded.
'1-LOADING: Loading is in progress, but file parsing has not yet begun.
'2-LOADED: Some files have been loaded and parsed, but the object model has not yet taken effect.
'3-INTERACTIVE: Only valid for loaded partial files, in which case the object model is valid but read-only.
'4-COMPLETED: The file has been completely loaded, indicating that the loading is successful.
fopen=objXML.ResponseBody
fopen=BytesToBstr(objXML.ResponseBody)' returns information and uses function definition encoding. If you need to transcode, please select
Set objXML=Nothing'Close
If Err.number<>0 Then
Response.Write "{status:0,errCode:100,message:'Error getting data'}"
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" 'Convert the original default encoding to GB2312 encoding, otherwise directly using XMLHTTP to call a webpage with Chinese characters will result in garbled codes
BytesToBstr = objstream.ReadText
objstream.Close
Set objstream = Nothing
End Function
'Enter query results
Response.Write ResponseTxt
%>