PHP 实现爱查快递接口
2012-06-18 13:14
218 查看
连接爱查快递接口的方法
一、首先去爱查快递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
get.php
总共的书写代码就这些,希望对大家有所帮助,如有问题及时联系qq:523132661.
一、首先去爱查快递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
<!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 header('Content-type:text/html;charset=utf-8'); //echo '*****'; $typeCom = $_GET["expressid"];//快递公司 $typeNu = $_GET["expressno"]; //快递单号 $key='**********';//到http://www.ickd.cn/api/reg.html申请 $url ='http://api.ickd.cn/?com='.$typeCom.'&nu='.$typeNu.'&id='.$key.'&type=html&encode=utf8'; //echo $url; $data = file_get_contents($url); echo $data; ?>
总共的书写代码就这些,希望对大家有所帮助,如有问题及时联系qq:523132661.
相关文章推荐
- 用PHP实现飞信api接口发飞信短信
- PHP内核探索:继承与实现接口
- Dcloud中mui 微信支付接口完美实现付款代码(PHP微信支付demo)
- PHP彩信接口开发经验及具体开发实现
- PHP调用微博接口实现微博登录的方法示例
- 调用支付宝PHP接口API实现在线即时支付功能(UTF-8编码)
- php开发app接口之android端的简易实现
- PHP接口的介绍与实现
- PHP接口多继承及tarits实现多继承效果的方法
- app接口设计之token的php实现
- 教你实现PHP支付宝接口
- php接口的实现
- PHP接口的介绍与实现(转)
- 农行支付接口的PHP实现
- php 多态与接口学习实现与实例代码
- php版微信公众号接口实现发红包的方法
- PHP类实例教程(二十三):PHP抽象类实现接口
- php利用接口实现类的多重继承
- PHP以接口方式实现多重继承(完全模拟)--学习笔记
- php利用反射真正实现多继承(非接口模拟)