3
回答
js对接微信连wifi提示Uncaught SyntaxError: Unexpected token ILLEGAL
科大讯飞通用文字识别100000次/天免费使用。立即申请   
<script type="text/javascript">
		/**
		 * 微信连Wi-Fi协议3.1供运营商portal呼起微信浏览器使用
		 */
		var loadIframe = null;
		var noResponse = null;
		 
		function putNoResponse(ev){
			 clearTimeout(noResponse);
		}	
		
		 function errorJump()
		 {
			 alert('该浏览器不支持自动跳转微信请手动打开微信\n如果已跳转请忽略此提示');
		 }
		 
		 myHandler = function(error) {
			 errorJump();
		 };
		 
		 function createIframe(){
			 var iframe = document.createElement("iframe");
		     iframe.style.cssText = "display:none;width:0px;height:0px;";
		     document.body.appendChild(iframe);
		     loadIframe = iframe;
		 }
		//注册回调函数
		function jsonpCallback(result){  
			if(result && result.success){
			    alert('WeChat will call up : ' + result.success + '  data:' + result.data);			    
			    var ua=navigator.userAgent;              
				if (ua.indexOf("iPhone") != -1 ||ua.indexOf("iPod")!=-1||ua.indexOf("iPad") != -1) {   //iPhone             
					document.location = result.data;
				}else{
					
					if('false'=='true'){
						alert('[强制]该浏览器不支持自动跳转微信请手动打开微信\n如果已跳转请忽略此提示');
						return;
					}
					
				    createIframe();
				    loadIframe.src=result.data;
					noResponse = setTimeout(function(){
						errorJump();
			      	},3000);
				}			    
			}else if(result && !result.success){
				alert(result.data);
			}
		}
		
		function Wechat_GotoRedirect(appId, extend, timestamp, sign, shopId, authUrl, mac, ssid, bssid){
			
			//将回调函数名称带到服务器端
			var url = "https://wifi.weixin.qq.com/operator/callWechatBrowser.xhtml?appId=" + appId 
																				+ "&extend=" + extend 
																				+ "&timestamp=" + timestamp 
																				+ "&sign=" + sign;	
			
			//如果sign后面的参数有值,则是新3.1发起的流程
			if(authUrl && shopId){
				
				
				url = "https://wifi.weixin.qq.com/operator/callWechat.xhtml?appId=" + appId 
																				+ "&extend=" + extend 
																				+ "&timestamp=" + timestamp 
																				+ "&sign=" + sign
																				+ "&shopId=" + shopId
																				+ "&authUrl=" + encodeURIComponent(authUrl)
																				+ "&mac=" + mac
																				+ "&ssid=" + ssid
																				+ "&bssid=" + bssid;
				
			}			
			
			//通过dom操作创建script节点实现异步请求  
			var script = document.createElement('script');  
			script.setAttribute('src', url);  
			document.getElementsByTagName('head')[0].appendChild(script);
		}
	</script>
    <link rel="stylesheet" href="https://wifi.weixin.qq.com/resources/css/style-simple-follow.css"/>
</head>
<body class="mod-simple-follow">
<div class="mod-simple-follow-page">
    <div class="mod-simple-follow-page__banner">
        <img class="mod-simple-follow-page__banner-bg" src="https://wifi.weixin.qq.com/resources/images/background.jpg" alt=""/>
        <div class="mod-simple-follow-page__img-shadow"></div>
        <div class="mod-simple-follow-page__logo">
            <img class="mod-simple-follow-page__logo-img" src="https://wifi.weixin.qq.com/resources/images/t.weixin.logo.png" alt=""/>
            <p class="mod-simple-follow-page__logo-name"></p>
            <p class="mod-simple-follow-page__logo-welcome">欢迎您</p>
        </div>
    </div>
    <div class="mod-simple-follow-page__attention">
        <p class="mod-simple-follow-page__attention-txt">欢迎使用微信连Wi-Fi</p>
        <a class="mod-simple-follow-page__attention-btn" onclick="callWechatBrowser()">一键打开微信连Wi-Fi</a>
    </div>
</div>
</body>
<script type="text/javascript">
	function callWechatBrowser(){
		Wechat_GotoRedirect('wxb069aeef0a797e59', 'demoNew', '<?php
function getMillisecond() {
list($t1, $t2) = explode(' ', microtime());
return (float)sprintf('%.0f',(floatval($t1)+floatval($t2))*1000);
}
echo getMillisecond(); ?>', '<?php echo md5($wxpwd."+demoNew+".getMillisecond()."+7360720+http://wifi.weixin.qq.com/assistant/wifigw/auth.xhtml?httpCode=200+"."ff:ff:ff:ff:ff:ff+ff:ff:ff:ff:ff:ff+".$wxysid);?>', '7360720', 'http://wifi.weixin.qq.com/assistant/wifigw/auth.xhtml?httpCode=200', 'aa:aa:aa:aa:aa:aa', '7360720', 'ff:ff:ff:ff:ff:ff');
	}
</script>



<script type="text/javascript">
	document.addEventListener('visibilitychange', putNoResponse, false);
</script>



举报
Liberxue
发帖于3年前 3回/1K+阅
共有3个答案 最后回答: 3年前

引用来自“wuyiw”的评论

body后面的php代码字符串换行了, js不支持字符串换行的.
应该怎么处理啊  我输出 对比了 签名 是没有问题 换行的啊
--- 共有 1 条评论 ---
wuyiw我看错了, 不是换行的问题. 3年前 回复

引用来自“wuyiw”的评论

估计问题在php的输出上, 有特殊字符之类的

 这个是php输出没有加密的sign   

wxb069aeef0a797e59+demoNew+1446386190764+7360720+http://wifi.weixin.qq.com/assistant/wifigw/auth.xhtml?httpCode=200+ff:ff:ff:ff:ff:ff+ff:ff:ff:ff:ff:ff+1e6657233b535a339d50257c2966b4cd   

 http://mp.weixin.qq.com/wiki/2/55f1e301f4558846d2bf0dd51543e252.html  这个是为微信官网的例子  签名错误 请求正确  微信后台监控提成接入成功了  就是签名老不对  

sign = MD5(appId + extend + timestamp + shop_id + authUrl + mac + ssid + bssid + secretkey);

--- 共有 1 条评论 ---
wuyiw这个错误发生在哪一行? 3年前 回复
顶部