微信企業號JS SDKphp
<?php define('CorpID', "wx82e2c31215d9a5a7"); define('CorpSecret', ""); //設置->功能設置->權限管理->系統管理組->深圳管理(新建的管理組)->Secret define('AgentID', "24"); //應用ID require_once('wxqiye.class.php'); $weixin = new class_wxqiye(); $signPackage = $weixin->GetSignPackage(); ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, minimum-scale=1.0, user-scalable=no" /> <meta name="format-detection" content="telephone=no" /> <title>微信企業JSSDK</title> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0"> <link rel="stylesheet" href="http://demo.open.weixin.qq.com/jssdk/css/style.css"> </head> <body ontouchstart=""> </body> <script src="https://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script> <script> wx.config({ debug: false, appId: '<?php echo $signPackage["appId"];?>', timestamp: <?php echo $signPackage["timestamp"];?>, nonceStr: '<?php echo $signPackage["nonceStr"];?>', signature: '<?php echo $signPackage["signature"];?>', // url:'<?php echo $signPackage["url"];?>', jsApiList: [ // 全部要調用的 API 都要加到這個列表中 'checkJsApi', 'openLocation', 'getLocation', ] }); </script> <script> wx.ready(function () { //自動執行的 wx.checkJsApi({ jsApiList: [ 'getLocation', ], success: function (res) { alert(JSON.stringify(res)); } }); wx.hideOptionMenu(); //若是不支持則不會執行 wx.getLocation({ success: function (res) { alert(JSON.stringify(res)); // alert('經度' + res.longitude); // alert('緯度' + res.latitude); // window.location.href = "location.php?longitude=" + res.longitude + "&latitude=" + res.latitude; }, cancel: function (res) { alert('用戶拒絕受權獲取地理位置'); } }); }); wx.error(function (res) { alert(res.errMsg); }); </script> </html>