PHP实现爱查快递接口
连接爱查快递接口的方法
一、首先去爱查快递http://www.ickd.cn/api/reg.html申请KEY,很快的,几分钟就申请下来了。比快递100好多了,服务也好多了。
二、创建表单,提交数据,发送地址为:$url ='http://api.ickd.cn/?com='.$typeCom.'&nu='.$typeNu.'&id='.$key.'&type=html&encode=utf8';
只要把表达那的值带进去就行了,就可以提交了。
实现代码为:
example.html
[html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>快递单号获取接口API - Example</title>
<script language="javascript" src="jquery-1.4.4.min.js"></script>
<script language="javascript">
$(document).ready(function(){
$("#btnSnap").click(function(){
$("#shipping_detail").html("<img src='load.gif' />");
var expressid = $("#expressid").val();
var expressno = $("#expressno").val();
//$.get("api/kuaidi.php",{expressid:expressid,expressno:expressno},function(data){
$.ajax({
async: false,
type : "get",
//contentType : "application/json;charset=ut",
dataType : "html",
url : "get.php",
data : "expressid=" +expressid + "&expressno=" + expressno,
success : function(msg) {// msg为返回的数据,在这里做数据绑定 $("#shipping_detail").html(msg); }
});
});
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$("tr:even").css("background-color","#EAF2D3");
});
</script>
<style>
#retForm{width:640px;line-height:22px;padding-bottom:10px;border-bottom:1px dotted #ccc;}
#retData{
background:#efefef;
padding:10px;
line-height:18px;
width: 96%;
border: 0;
}
.txtPartner{width:960px;margin:20px 10px;padding:10px 0 0 0;border-top:1px solid #dfdfdf;}
.txtPartner h1{font-size:14px;color:#FF5632;}
.txtPartner a{float:left;margin:0 10px 10px 0;}
.logo {
font-size: 18px;
font-weight: bold;
text-align: center;
padding: 10px;
font-family: "微软雅黑";
}
.txtURL {
font-size: 12px;
padding: 10px;
}
</style>
<style>
.ickd_return{
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
width:100%;
border-collapse:collapse;
}
th,td {
font-size:1em;
border:1px solid #98bf21;
padding:3px 7px 2px 7px;
text-align:center;}
th{
text-align:center;
font-size:1.1em;
padding-top:5px;
padding-bottom:4px;
background-color:#A7C942;
color:#ffffff;}
tr.td{
color:#000000;
background-color:#EAF2D3;
}
</style>
<style>
#retForm{width:640px;line-height:22px;padding-bottom:10px;border-bottom:1px dotted #ccc;}
#retData{
background:#efefef;
padding:10px;
line-height:18px;
width: 96%;
border: 0;
}
.txtPartner{width:960px;margin:20px 10px;padding:10px 0 0 0;border-top:1px solid #dfdfdf;}
.txtPartner h1{font-size:14px;color:#FF5632;}
.txtPartner a{float:left;margin:0 10px 10px 0;}
.logo {
font-size: 18px;
font-weight: bold;
text-align: center;
padding: 10px;
font-family: "微软雅黑";
}
.txtURL {
font-size: 12px;
padding: 10px;
}
</style>
</head>
<body>
<div class="result">
</div>
<!-- <form action="kuaidi.php" method="get"> -->
<div class="seatchForm">
<div class="txtURL">
<p>快递公司:
<input name="expressid" type="text" id="expressid" />
快递单号:<input name="expressno" type="text" id="expressno"/>
</p>
<p>说明:查询时需要发送两个参数:公司名(拼音或英文);快递单号</p>
</div>
<div class="txtButton"><input type="submi
补充:Web开发 , php ,