我正在开发针对ios& amp;的Cordova混合应用程序需要在登录页面通过微信添加身份验证。
$scope.wechatLogin=function(){
scope = "snsapi_userinfo",state = "_" + (+new Date());
Wechat.auth(scope, state, function (response) {
alert(JSON.stringify(response));
$.get('https://api.weixin.qq.com/sns/oauth2/access_token?myappid=' + appId + '&secret=' + myappSecret + '&code=' + response.code + '&grant_type=authorization_code', function (accessTokenResponse) {
alert(JSON.stringify(accessTokenResponse));
// you should save access token response somewhere, e.g. cookies, local storage, etc.
var accessToken = accessTokenResponse.access_token;
var openId = accessTokenResponse.openid;
// get user information
$.get('https://api.weixin.qq.com/sns/userinfo?access_token=' + accessToken + '&openid=' + openId + '&lang=zh_CN', function (userInfoResponse) {
console.log(userInfoResponse);
});
});
});
}
在设备上进行测试时,会打开微信&给出一条消息“oops!出了问题”。你能帮我解决这个问题。
非常感谢!