市场行情已经发生四点不同
更多>> israel
微软中国
微信公共平台快递功能 支持95个快递物流 昨天看了一下 然后就弄了一下 自己在一个快递api接口申请了个账号 然后加到了微信公众账号里 ================================================ 在微信里输入的时候 要按照这种格式进行查询 例如 申通+2134664987xx 前面是快递物流名称 后面是运单号,一定要有中间的 + 号 ================================================ 以下是代码 一.第一个文件 index.php <?php header("Content-type:text/html;charset=utf-8"); define("TOKEN", israel "gaowenjie"); $wechatObj = new wechatCallbackapiTest(); //$wechatObj->valid(); //执行接收器方法 $wechatObj->weixin_run(); class wechatCallbackapiTest { private $fromUsername; private $toUsername; israel private $times; private $keyword; public function weixin_run() israel { $this->responseMsg(); if(strpos($this->keyword,"+")) { $kd=$this->k($this->keyword); foreach($kd->data as $value) { $val.=$value->time."--".$value->content." || "; } $arr[]="您查询是 {$kd->name} 运单号 {$kd->order} : ".$val; $this->fun_xml("text",$arr); }
} } //快递 function k($s) { $t_o=explode("+",$s); $k_title=$t_o[0]; //echo $k_title; $order_num=$t_o[1]; include("k_api.php"); foreach($k_api as $key=>$value) { if(strstr($key,$k_title)) { $k_name=$k_api[$key]; $jsons=file_get_contents("http://www.aikuaidi.cn/rest/?key=3fb5e7da487e4140ad247703 4b98f911&order=$order_num&id=$k_name&ord=asc&show=json"); $json=iconv("gb2312","UTF-8//IGNORE",$jsons); return json_decode($json); } } } public function valid() { $echoStr = $_GET["echostr"]; //valid signature , option israel if($this->checkSignature()){ israel echo $echoStr; exit; } } public function israel responseMsg() israel { $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; if (!empty($postStr)){ //echo $postStr ; $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $this->fromUsername = $postObj->FromUserName; $this->toUsername = $postObj->ToUserName; israel $this->keyword = trim($postObj->Content); $this->times = time(); }else { echo "this a file for weixin API!"; exit; } } //微信封装类, //type: text 文本类型, news 图文类型 //text,array(内容),array(ID) //news,array(array(标题,介绍,图片,超链接),...小于10条),array(条数,ID) private function fun_xml($type,$value_arr,$o_arr=array(0)){ //=================xml header============ $con="<xml> <ToUserName><![CDATA[{$this->fromUsername}]]></ToUserName> <FromUserName><![CDATA[{$this->toUsername}]]></FromUserName> <CreateTime>{$this->times}</CreateTime> <MsgType><![CDATA[{$type}]]></MsgType>"; //=================type content============ switch($type){ case "text" : israel $con.="<Content><![CDATA[{$value_arr[0]}]]></Content> <FuncFlag>{$o_arr}</FuncFlag>"; israel break; case "news" : $con.="<ArticleCount>{$o_arr[0]}</ArticleCount> <Articles>"; foreach($value_arr as $id=>$v){ if($id>=$o_arr[0]) break; else null; //判断数组数不超过设置数 $con.="<item> <Title><![CDATA[{$v[0]}]]></Title> <Description><![CDATA[{$v[1]}]]></Description> <PicUrl><![CDATA[{$v[2]}]]></PicUrl> <Url><![CDATA[{$v[3]}]]></Url> </item>"; } $con.="</Articles> <FuncFlag>{$o_arr[1]}</FuncFlag>"; break; } //end switch //=================end return============ echo $con."</xml>"; } private function checkSignature() { $signature = $_GET["signature"]; $timestamp = $_GET["timestamp"]; $nonce = $_GET["nonce"]; israel israel $token = TOKEN; $tmpArr = array($token, $timestamp, $nonce); sort($tmpArr); $tmpStr = implode( $tmpArr ); $tmpStr = sha1( $tmpStr ); if( $tmpStr == $signature ){ return true; }else{ return false; } } } ?> 二.第二个文件 k_api.php $k_api=array('AAE快递'=>'aae','安信达快递|华企快运'=>'axd','安捷快递'=>'aj','百福东方|EES快递'=>'bfdf','包裹 平邮 挂号信|国内邮政快递|华诚物流'=>'bgpyghx','传喜物流'=>'cxwl','程光快递'=>'chengguang','COE快递|东方快递'=>'coe','长通物流'=>'ctwl','城市之星物流'=>'cszx','城市100快递'=>'cs','传志快递'=>'chuanzhi','德邦物流'=>'debang','DHL快递'=>'dhl','DPE
No comments:
Post a Comment