微擎簽名出錯
錯誤信息: config:fail,Error: 系統錯誤,錯誤碼:63002,invalid signature
修改方法:
PHP 端
$account_api = WeAccount::create(); $jssdk = $account_api->getJssdkConfig("當前網頁的URL"); // 關閉調試模式 $jssdk['debug'] = false; // 選擇使用獲取地圖信息的API $jssdk['jsApiList'] = ['getLocation']; exit(json_encode($jssdk));
HTML 端
<script> $.post("請求地址", 請求參數, function (data) { // 將返回的簽名數據寫入到wx.config中 wx.config(data); console.log(data); wx.getLocation({ type: 'gcj02', // 默認為wgs84的gps坐標,如果要返回直接給openLocation用的火星坐標,可傳入'gcj02' success: function (res) { var latitude = res.latitude; // 緯度,浮點數,范圍為90 ~ -90 var longitude = res.longitude; // 經度,浮點數,范圍為180 ~ -180。 var speed = res.speed; // 速度,以米/每秒計 var accuracy = res.accuracy; // 位置精度 console.log(res); } }); }, 'json'); </script>