【微信开发】-发送位置进行Route Matrix API v2.0批量算路接口, 主要代码在private function receiveLocation($object)

Route Matrix API v2.0 Beta是一套以HTTP/HTTPS形式提供的批量算路接口,返回路线规划距离和行驶时间。

Route Matrix API v2.0 Beta是原v1.0接口的升级版,升级内容如下:
起终点个数由原来的分别不超过5个,调整为起终点乘积不超过50。
起终点输入仅支持坐标,不再支持输入关键字。
其他调整,详见接口说明。
功能介绍

批量计算路线的距离和耗时
支持驾车、骑行和步行三种形式
步行时任意起终点之间的距离不得超过200KM,超过此限制会返回参数错误
一次最多计算50条路线,起终点个数之积不能超过50。 比如2个起点25个终点,50个起点1个终点等

详见官网:http://lbsyun.baidu.com/index.php?title=webapi/route-matrix-api-v2

<?
    header("Content-type: text/html; charset=utf-8");
    define("TOKEN","自填");
    define("APPID","自填");
    define("APPSECRET","自填");

    $wechatObj = new wechatCallbackapiTest();
    if(!isset($_GET["echostr"])){
        $wechatObj -> responseMsg();
    }else{
        $wechatObj ->valid();
    }

    class wechatCallbackapiTest{
     
        public function valid(){
     
            $echoStr = $_GET["echostr"];
        if($this->checkSignature()){
            echo $echoStr;
            exit;
        }
    }

    private function checkSignature(){
     
        if(!defined("TOKEN")){
            throw new Exception();
        }
        $signature = $_GET["signature"];
        $timestamp = $_GET["timestamp"];
        $nonce = $_GET["nonce"];
        $token = TOKEN;
        $tmpArr = array($token,$timestamp,$nonce);
        sort($tmpArr,SORT_STRING);
        $tmpStr = implode($tmpArr);
        $tmpStr = sha1($tmpStr);
        if($tmpStr == $signature){
            return true;
        }else{
            return false;
        }
    }

    public function responseMsg()
    {
     
        $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
        if (!empty($postStr)){
            $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
            $RX_TYPE = trim($postObj->MsgType);
            switch ($RX_TYPE)
            {
                case "event":
                    $result = $this->receiveEvent($postObj);
                    break;
                case "text":
                    $result = $this->receiveText($postObj);
                    break;
                case "image":
                    $result = $this->receiveImage($postObj);
                    break;
                case "location":
                    $result = $this->receiveLocation($postObj);
                    break;
                case "voice":
                    $result = $this->receiveVoice($postObj);
                    break;
                case "video":
                case "shortvideo":
                    $result = $this->receiveVideo($postObj);
                    break;
                case "link":
                    $result = $this->receiveLink($postObj);
                    break;
                default:
                    $result = "unknown msg type: ".$RX_TYPE;
                    break;
            }
            echo $result;
        }else {
            echo "";
            exit;
        }
    }

    private function receiveEvent($object)
    {
     
        include("locationinfoUpload.php");
        $resInsert = insertLocationinfo($object);
        $content = "";
        switch ($object->Event)
        {
            case "subscribe":
                $content = "欢迎关注通州-羽我同行俱乐部!\n请回复以下关键字:文本 表情 单图文 多图文 音乐\n请按住说话 或 点击 + 再分别发送以下内容:语音 图片 小视频 我的收藏 位置";
                $content .= (!empty($object->EventKey))?("\n来自二维码场景 ".str_replace("qrscene_","",$object->EventKey)):"";
                $content .= "\n\n".'<a href="羽我同行.cn">技术支持 大米</a>';
                break;
            case "unsubscribe":
                $content = "取消关注";
                break;
            case "CLICK":
                switch ($object->EventKey)
                {
                    case "78":
                        $content = array();
                        $content[] = array(

                     "Title"=>"天气在手,羽球无忧,输入“天气北京”", 

                     "Description"=>"天气在手,羽球无忧,羽我同行!

输入“天气北京”即可轻松查询,支持全国城市!", 

                     "PicUrl"=>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zyytaiyame

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值