Php express Query API-support for various types of express delivery-PHP source code

Source: Internet
Author: User
Php express Query API-support for various PHP codes

 Expressname = $ this-> expressname ();}/** method for collecting webpage content */private function getcontent ($ url) {if (function_exists ("file_get_contents ")) {$ file_contents = file_get_contents ($ url);} else {$ ch = curl_init (); $ timeout = 5; curl_setopt ($ ch, CURLOPT_URL, $ url ); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ ch, CURLOPT_CONNECTTIMEOUT, $ timeout); $ file_contents = curl_exec ($ ch); curl_close ($ ch ); } Return $ file_contents;}/** method for obtaining the corresponding name and value */private function expressname () {$ result = $ this-> getcontent ("http://www.kuaidi100.com/"); preg_match_all ("/data \-code \ = \"(? P
 
  
\ W +) \ "\> \(? P
  . *) \ <\/Span>/iU ", $ result, $ data); $ name = array (); foreach ($ data ['title'] as $ k => $ v) {$ name [$ v] = $ data ['name'] [$ k];} return $ name;}/** method for resolving an object into an array * @ param $ json input object array * return $ data array */private function json_array ($ json) {if ($ json) {foreach (array) $ json as $ k =>$ v) {$ data [$ k] =! Is_string ($ v )? $ This-> json_array ($ v): $ v ;}return $ data ;}} /** return the $ data array Courier array * @ param $ name Courier name * the supported Courier names are as follows * (shentong-EMS-sf-Yuantong-Zhongtong-ru Fengda-Yunda- daily-Huitong-Quanfeng-Debon-homebred express-amcinda-parcel pingmail-State delivery logistics * DHL Express-Daejeon logistics-Debon logistics-EMS domestic-EMS International-email Bao-FanKe distribution-Guotong express-registered letter-shared express-international parcel * Huitong express-Huayu logistics-Huiqiang express-Jiaji express-Jiayi logistics-Canada Post-Express-Longbang express-Federated express-lianhaotong * can express -for example, Fengda-Swedish Post Office-Quanyi Express-Quanfeng Express-quanzitong-Shentong Express-Shunfeng Express-Sauer express-TNT Express-Daily Express delivery * Tiandi Huayu-UPS Express-Xinbang logistics-singe logistics-Hong Kong postal Service-Yuantong Express-Yunda Express-postal package-High speed express-Zhongtong Express) * China Railway Express-home delivery-China Mail Logistics * @ param $ order express delivery ticket No. * $ data ['ischeck'] = 1 accepted * $ data ['data'] express delivery real-time query array */public function getorder ($ name, $ order) {$ keywords = $ this-> expressname [$ name]; $ result = $ this-> getcontent (" http://www.kuaidi100.com/query?type= {$ Keywords} & postid = {$ order} "); $ result = json_decode ($ result); $ data = $ this-> json_array ($ result ); return $ data ;}$ a = new Express (); $ result = $ a-> getorder ("all-one Express", 111309582915); var_dump ($ result);?> </Pre>
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.