国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > PHP > 正文

微信公眾號開發之獲取位置信息php代碼

2024-05-05 00:04:11
字體:
來源:轉載
供稿:網友

本文實例為大家分享了php微信公眾號獲取位置信息的具體代碼,供大家參考,具體內容如下

<?php/** * wechat php test *///define your tokendefine("TOKEN", "weixin");$wechatObj = new wechatCallbackapiTest();//$wechatObj->valid();$wechatObj->responseMsg();class wechatCallbackapiTest{ public function valid() {  $echoStr = $_GET["echostr"];  //valid signature , option  if($this->checkSignature()){   echo $echoStr;   exit;  } } public function responseMsg() {  //get post data, May be due to the different environments  $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];  //extract post data  if (!empty($postStr)){    $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);    $fromUsername = $postObj->FromUserName;    $toUsername = $postObj->ToUserName;    $type = $postObj->MsgType;    $customevent = $postObj->Event;    $latitude = $postObj->Location_X;    $longitude = $postObj->Location_Y;    $keyword = trim($postObj->Content);    $time = time();    $textTpl = "<xml>       <ToUserName><![CDATA[%s]]></ToUserName>       <FromUserName><![CDATA[%s]]></FromUserName>       <CreateTime>%s</CreateTime>       <MsgType><![CDATA[%s]]></MsgType>       <Content><![CDATA[%s]]></Content>       <FuncFlag>0</FuncFlag>       </xml>";        if($type=="event" and $customevent=="subscribe"){     $contentStr = "感謝你的關注/n回復1查看聯系方式/n回復2查看最新資訊/n回復3查看法律文書";     $msgType = "text";     $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);     echo $resultStr;     }     if($type=="image" ){     $contentStr = "你的圖片很棒!";     $msgType = "text";     $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);     echo $resultStr;     }     if($type=="location" ){     $contentStr = "你的緯度是{$latitude},經度是{$longitude},我已經鎖定!";     $msgType = "text";     $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);     echo $resultStr;     }      if(!empty( $keyword ))    {             $msgType = "text";     if($keyword=="1"){     $contentStr = "qiphon";}     if($keyword=="2"){     $contentStr = "test222";}     if($keyword=="3"){     $contentStr = "test333";}          $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);     echo $resultStr;    }else{     echo "Input something...";    }  }else {   echo "";   exit;  } } 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;  } }}?>

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VeVb武林網。


注:相關教程知識閱讀請移步到PHP教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 嵩明县| 临城县| 红原县| 伊春市| 南召县| 青田县| 扎囊县| 万源市| 依安县| 黎城县| 当阳市| 阿瓦提县| 芦溪县| 南木林县| 喜德县| 宕昌县| 晋城| 潢川县| 湖南省| 东莞市| 当阳市| 综艺| 三原县| 东兴市| 南漳县| 长宁县| 临汾市| 托克逊县| 苍溪县| 舞钢市| 佛山市| 丰顺县| 连平县| 辽源市| 迁西县| 郸城县| 会同县| 遵义县| 巴南区| 恩平市| 洞头县|