2014-09-05
连接爱查快递接口的方法
一、首先去爱查快递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="submit" value="查询" id="btnSnap" class="btnSnap"/></div>
</div>
<div class="txtAboutSnap">
<p>获取范例:</p>
<div id="shipping_detail"></div>
<img src="load.gif" />
</div>
</div>
</body>
</html>
get.php
[php]
<?php
header('Content-type:text/html;charset=utf-8');
//echo '*****';
$typeCom = $_GET["expressid"];//快递公司 www.zhishiwu.com
$typeNu = $_GET["expressno"]; //快递单号
$key='**********';//到<a href="http://www.ickd.cn/api/reg.html">http://www.ickd.cn/api/reg.html</a>申请
$url ='http://api.ickd.cn/?com='.$typeCom.'&nu='.$typeNu.'&id='.$key.'&type=html&encode=utf8';
//echo $url;
$data = file_get_contents($url);
echo $data;
?>
作者:hljflp
1
CI框架连接数据库配置操作以及多数据库操作
09-05
2
asp 简单读取数据表并列出来 ASP如何快速从数据库读取大量数据
05-17
3
C语言关键字及其解释介绍 C语言32个关键字详解
04-05
4
C语言中sizeof是什么意思 c语言里sizeof怎样用法详解
04-26
5
PHP中的魔术方法 :__construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep,
09-05
6
将视频设置为Android手机开机动画的教程
12-11
7
PHP中的(++i)前缀自增 和 (i++)后缀自增
09-05
8
最简单的asp登陆界面代码 asp登陆界面源代码详细介绍
04-12
常用dos命令及语法
2014-09-27
PHP中include和require区别之我见
2014-09-05
如何安装PHPstorm并配置方法教程 phpstorm安装后要进行哪些配置
2017-05-03
php递归返回值的问题
2014-09-05
单片机编程好学吗?单片机初学者怎样看懂代码
2022-03-21
PHP 教程之如何使用BLOB存取图片信息实例
2014-09-05
学ug编程如何快速入门?
2022-03-17
PHP数组函数array
2014-09-05
学习使用C语言/C++编程的7个步骤!超赞~
2022-03-20
零基础的初学者怎样学习java,或者应该先学什么?
2022-03-21
收割者剑客传奇免谷歌汉化版下载v2.0.1 安卓版
其它手游 40.19MB
下载
reaper收割者破解版下载v2.0.1 安卓完美版
其它手游 40.19MB
下载
reaper汉化版下载v2.0.1 安卓中文版
其它手游 40.19MB
下载
死神苍白剑士的传说中文版(Reaper)下载v2.0.1 安卓版
其它手游 40.19MB
下载
宝宝巴士迷宫小镇下载v9.89.99.01 官方安卓版
其它手游 113.4MB
下载
宝宝迷宫大作战游戏下载v9.89.99.01 安卓版
其它手游 113.4MB
下载
宝宝巴士干净的妙妙游戏下载v9.89.99.00 安卓版
其它手游 76.43MB
下载
妙妙爱干净宝宝巴士下载v9.89.99.00 安卓版
其它手游 76.43MB
下载翻炒厨师游戏下载v2.1.3 安卓版
下载
维塔战士游戏最新版下载v976 安卓版
下载
泡泡小镇城堡游戏下载v1.1.5 安卓完整版
下载
3d蚊子模拟器游戏最新版下载v2023.08.22 安卓版
下载
超级机器人英雄游戏下载v1.1.3 安卓版
下载
robot super游戏下载v1.1.3 安卓版
下载
zombie tsunami游戏下载v4.6.8 安卓版
下载
2026僵尸尖叫正版下载v4.6.8 安卓官方版
下载