PHP 兌現愛查快遞介面

來源:互聯網
上載者:User
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

<!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><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> <!-- <form action="kuaidi.php" method="get"> --> <p>快遞公司: <input name="expressid" type="text" id="expressid" /> 快遞單號:<input name="expressno" type="text" id="expressno"/> </p> <p>說明:查詢時需要發送兩個參數:公司名(拼音或英文);快遞單號</p><input type="submit" value="查詢" id="btnSnap" class="btnSnap"/><p>擷取範例:</p></body> </html>

get.php

<?phpheader('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.

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.