這裏首先需要解析消息類型, $input_type=$postObj->MsgType;
然後獲取消息裏面的定位經緯度 $loc_x=$postObj->Location_X;
$loc_y=$postObj->Location_Y;
接下來開始解析經緯度,
if($input_type=="location")
{
$msgType="text";
// 使用騰訊地圖計算距離
$contentStr="你發送的地點座標是($loc_x,$loc_y)";
$resultStr=sprintf($textTpl,$fromUsername,$toUsername,$time,$msgType,$contentStr);
echo$resultStr;
}
具體實現代碼就放在開源中國裏面 ,有什麼疑問的話歡迎留言交流, 知無不言.
https://Git.oschina.NET/RoseKissYou/wechat_subscribe/attach_files