Send the following content to the public platform: for example, query ecmsAPELAX1040039963 or Yike (Yike is full) if the ticket number is APELAX1040039963) APELAX1040039963 [there must be a space between the express delivery company name and the express delivery number] Note: This project uses the kuaidi100 API; the other beauty
Send the following content to the public platform: for example, query ecmsAPELAX1040039963 or Yike (Yike is full) if the ticket number is APELAX1040039963) APELAX1040039963 [there must be a space between the express delivery company name and the express delivery number] Note: This project uses the kuaidi100 API; the other beauty
Yixin/public platform query Express
To use this method, edit the following content and send it to the public platform:
For example, query the express delivery with the ticket No. APELAX1040039963
Ecms APELAX1040039963 or Yike (Yike full) APELAX1040039963 [there must be a space between the express delivery company name and express delivery number]
Note: This project uses the kuaidi100 API;
In addition, the elasticsearch Express used by Amazon in the United States is a self-written collection,
Hand Exercises (the previous ones were too rough ~), Thank you for your correction and comments ~
In fact, you can add a database, a scheduled task, and a/email message sending function to implement real-time update of express delivery. (This is what I want to do later ~)
There are too many files. Please move to all projects:
GitHub: https://github.com/skiy/express
My blog: www.skiy.net <无>
Token = $ token;} // determines whether the server is from the public function valid () {$ echoStr = $ _ GET ["echostr"]; if ($ this-> checkSignature ()) {echo $ echoStr; exit ;}} */private $ toUsername; private $ fromUsername; private $ createTime; private $ msgId; private $ msgType; private $ time; private $ content; private $ postStr; public function responseMsg () {$ postStr = $ GLOBALS ["HTTP_RAW_POST_DATA"]; $ this-> postObj = simplexml_load_str Ing ($ postStr, 'simplexmlelement', LIBXML_NOCDATA); $ this-> toUsername = $ this-> postObj-> ToUserName; $ this-> fromUsername = $ this-> postObj-> FromUserName; $ this-> createTime = $ this-> postObj-> CreateTime; $ this-> msgId = $ this-> postObj-> MsgId; $ this-> msgType = $ this-> postObj-> MsgType; $ this-> time = time (); $ resultStr = "error"; if (! Empty ($ postStr) {$ resultStr = $ this-> get_text ();} echo $ resultStr;} // receives the public function get_text () {$ textTpl ="
%s
%s
% S
%s
%s
"; If ($ this-> msgType! = "Text") {$ content = "Incorrect express delivery information. ";}Else {$ this-> content = $ this-> postObj-> Content; $ this-> content = preg_replace ("/(\ s {2 ,}) /"," ", $ this-> content); $ content_list = explode (" ", $ this-> content); if (count ($ content_list) = 2) {include_once "get_companies.php"; $ company = new company (); $ company_infos = $ company: get_companies_info ($ content_list [0]); // if courier 100 does not support this courier, diy if (count ($ company_infos) = 0) {$ is_diy = true; $ company: $ Companies = include_once 'fetch/add_companies.php '; $ company_infos = $ company: get_companies_info ($ content_list [0]);} $ num = $ content_list [1]; $ code = $ company_infos [0] ['code']; // obtain the English code $ com = $ company_infos [0] ['company']; // get company name $ numinfo = "courier :". $ com. "\ n ". "Ticket No :". $ num. "\ n"; if (! $ Is_diy) {$ kd_url =" http://m.kuaidi100.com/query?type= ". $ Code. "& postid = ". $ num;} else {$ kd_url = dirname ('HTTP ://'. $ _ SERVER ['server _ name']. $ _ SERVER ["REQUEST_URI"]). '/fetch/index. php? Code = '. $ code. "& postid = ". $ num ;}$ json_getdata = Response ($ kd_url); // $ get_kdinfo = json_decode ($ json_getdata); // object $ get_kdinfo = json_decode ($ json_getdata, true ); // array $ last_t = "query time: \ n ". $ get_kdinfo ['updatetime']. "\ n"; // query time $ kd_shipinfo = $ get_kdinfo ['data']; // express data array $ kd_total = count ($ kd_shipinfo)-1; $ ship = ''; $ detail =" \ n click to View Details "; // logistics Reverse Order details for ($ I = $ kd_total; $ I> = 0; $ I --) {$ shipinfo = $ kd_shipinfo [$ I] ['time']. "\ n ". $ kd_shipinfo [$ I] ['context']. "\ n"; $ ship = $ shipinfo. $ ship;} // details of ordered Logistics/* foreach ($ kd_shipinfo as $ v) {$ shipinfo = $ v ['time']. "\ n ". $ v ['context']. "\ n"; $ ship = $ shipinfo. $ ship;} */$ get_kdinfo = $ numinfo. $ last_t. "[logistics details] \ n ". $ ship; if ($ ship) {$ contentStr = $ get_kdinfo;} else {$ contentStr = $ numinfo. "> no logistics data! ". $ Kd_url;} $ contentStr. = $ detail;} else {$ contentStr = "format error. The correct format is as follows: \ n express delivery company name express Waybill No." ;}}$ resultStr = sprintf ($ textTpl, $ this-> fromUsername, $ this-> toUsername, $ this-> time, "text", $ contentStr); return $ resultStr;} // judge the signature, return bool private function checkSignature () {$ signature = $ _ GET ["signature"]; $ timestamp =$ _ GET ["timestamp"]; $ nonce = $ _ GET ["nonce"]; $ token = TOKEN; $ tmpArr = array ($ token, $ timestamp, $ nonce); sort ($ tmpArr ); $ tmpStr = implode ($ tmpArr); $ tmpStr = sha1 ($ tmpStr); if ($ tmpStr ==$ signature) {return true;} else {return false ;}}}
Get_companies ();}/** return array companies infos */public static function get_companies () {return include_once self: $ file_name ;} /** get the company name through encoding * @ param string $ code encoding * return string company name */public static function get_company_name ($ code) {foreach (self :: $ companies as $ keys =>$ values) {if ($ values ['code'] ==$ code) {return $ values ['company'] ;}} return ;} /** get encoding by company name * $ param string $ name company name * return string encoding */public static function get_company_code ($ name) {foreach (self :: $ companies as $ keys =>$ values) {if ($ values ['name'] ==$ name) {return $ values ['code'] ;}} return ;} /** complete encoding obtained by courier company name or code fuzzy search all * $ param string $ input company name * return array encoding and company name */public static function get_companies_info ($ input) {$ lists = array (); foreach (self: $ companies as $ keys => $ values) {if (mb_stristr ($ values ['company'], $ input )) {unset ($ values ['id']); $ lists [] = $ values ;}} // if the value cannot be obtained by name, use the key name if (count ($ lists) = 0) {foreach (self: $ companies as $ keys => $ values) {if (mb_stristr ($ values ['code'], $ input) {unset ($ values ['id']); $ lists [] = $ values ;}}} return $ lists;}/** get the encoding and company name directly without type * @ param string encoding or company name * return array encoding and company name */public static function get_company_info ($ input) {foreach (self ::$ companies as $ keys = >$ values) {if (in_array ($ input, $ values) {unset ($ values ["id"]); return $ values ;}} return ;}}
* @ Created: 1/6/15 * @ modified: * // lang = {cn/en} // https://www.ecmsglobal.com/oms/showtracking? Trackingno = APELAX1040039963 & lang = cn // $ lang = "cn"; $ postid = isset ($ _ GET ['postid'])? $ _ GET ['postid']: 0; $ kd_url = "https://www.ecmsglobal.com/oms/showtracking? Trackingno = {$ postid} & lang = {$ lang} "; $ page_info = file_get_contents ($ kd_url); // $ page_info = file_get_contents (" a.html "); $ page_dom ="
". $ Page_info; $ xmldoc = new DOMDocument (); @ $ xmldoc-> loadHTML ($ page_dom); $ xmldoc-> normalizeDocument (); $ page_xml = new Domxpath ($ xmldoc ); $ event_date = $ page_xml-> query ('// p [@ class = "order"] // ul // p [@ class = "column event_date"]'); $ event_where = $ page_xml-> query ('// p [@ class = "order"] // ul // p [@ class = "column event_where"]'); $ event_desc = $ page_xml-> query ('// p [@ class = "order"] // ul // p [@ class = "column event_desc"]'); $ thisinfo = array (); $ add_infos = array (); foreach ($ event_date as $ keys = >$ values) {$ location = $ event_where-> item ($ keys) -> textContent; $ context = $ event_desc-> item ($ keys)-> textContent; $ thisinfo [] = array ('time' => $ values-> textContent, 'location' => $ location, 'context' => $ location. ", \ n ". $ context,);} if (count ($ thisinfo)> 0) {$ add_infos = array ('message' => "OK", 'nu '=> $ postid, 'companytype' => "ecms", 'ischeck' => "1", 'com' => "ecms", 'updatetime' => $ event_date-> item (0) -> textContent, 'status' => "200", 'codenumber' => $ postid, 'data' => $ thisinfo);} return $ add_infos;