PHP Express Query

Source: Internet
Author: User

http://www.oschina.net/code/snippet_60100_25087

<?phpclass Express {private $expressname =array ();//encapsulates The Courier name function __construct () {$this-&gt    ; expressname = $this->expressname ();             }/* * method for capturing Web 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; }/* * Gets the corresponding name and the corresponding pass value method */Private Function Expressname () {$result = $this->getcontent ("http://www.k        uaidi100.com/"); Preg_match_all ("/data\-code\=\" (? p<name>\w+) \ "\>\<span\> (?        p<title>.*) \<\/span>/iu ", $result, $data);        $name = Array (); ForeAch ($data [' title '] as $k = + $v) {$name [$v] = $data [' name '] [$k];    } return $name; }/* * method to parse the object array * @param $json input Object Arrays * Return $data array */Private function Json_arr Ay ($json) {if ($json) {foreach (array) $json as $k = = $v) {$data [$k] =!is_string ($v)? $th            Is->json_array ($v): $v;        } return $data; }/* * Returns an array of $data arrays * @param $name Express name * The name of The courier support entered is as follows * (Shen Tong-ems-Shun Fung-Yuantong-Zhong Tong-such as Wind Tatsu-Yun da-daily-Huitong-Pang-darbond-Home delivery-An Sinda-Parcel Mail-FedEx Logistics * DHL Express-Daejeon Logistics-de bang Logistics-ems domestic-ems International e-mail Bao-van Courier-China Express-registered-total speed-International parcel * Huitong Express-Huayu Logistics-hui Qiang Express-Jia Ji Express -Jia Yi Logistics-Canada Post-Express-Express-Longbang Express-FedEx-Union Hao Tong * can reach Courier-like the wind-Sweden post-all one Express-Pang Express-full-day pass-Shentong Express-Shun Fung Express-Express Courier-tnt Express-Daily Express * heaven and earth Huayu-ups Express-new state logistics-new Egg logistics-Hongkong Post -Yuantong Express-Yun da Express-Postal parcel-excellent speed express-in the express delivery-in-rush-home Delivery-Mail Logistics * @param $order Courier number * $data [' Ischeck '] ==1 has signed * $d    ata[' data ' express real-time query status 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-in-one Express", "111309582915"); Var_dump ($result);? >

  

PHP Express Query

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.