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"=>