php网页调用微信扫码实现扫码录入完整实例

cs.php
<?php
header("Content-type:text/html;charset=utf-8");
error_reporting(0);
$a=$_GET["a"];
$pici=$_GET["pici"];
require_once "jssdk.php";
$jssdk = new JSSDK("你的公众号AppID", "你的公众号AppSecret");
$signPackage = $jssdk->GetSignPackage();
?>
<!DOCTYPE>
<html>
<head><meta name="viewport" content="width=320.1,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"><link rel="stylesheet" href="style.css"/><script src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"> </script><script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
</head>
<body><input type="text" name="" value=""><input type="text" name="" value=""><button class="btn btn_primary" id="scanQRCode1">扫码</button><script type="text/javascript">wx.config({debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。appId: '',timestamp: '',nonceStr: '',signature: '',jsApiList: ['checkJsApi','scanQRCode'// 微信扫一扫接口] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2});wx.ready(function(){wx.hideOptionMenu();document.querySelector('#scanQRCode1').onclick = function () {wx.scanQRCode({needResult: 1,desc: 'scanQRCode desc',success: function (res) {str=JSON.stringify(res);str = str.substr(0, str.indexOf('","e'));str=str.substring(14);var pici=""location.href='你的域名+路径/cs.php?pici='+pici+ '&a=' + str;}});};});//初始化jsapi接口 状态wx.error(function (res) {alert("调用微信jsapi返回的状态:"+res.errMsg);});
</script>
</body>
</html>


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部