wap接入微信、qq第三方登录

一、qq登录

1、申请,创建应用

https://connect.qq.com/


输入相关信息,主要的网站域名和回调地址,回调地址新改的规则是要很完整填写

获取到app id和app key

2、查看qq登录文档

http://wiki.open.qq.com/wiki/website/%E6%94%BE%E7%BD%AE%E2%80%9CQQ%E7%99%BB%E5%BD%95%E2%80%9D%E6%8C%89%E9%92%AE_OAuth2.0

1)qq按钮

  <a href="#" onclick='qqLogin()'>
  <img src="img/qq_login.png"></a>


2)获取code

PC网站: https://graph.qq.com/oauth2.0/authorize (官网文档虽然是wap,但调用wap的时候显示网页不存在,所以选择了pc)


$scope. qqLogin = function(){
$scope. Redirect_uri_qq = encodeURIComponent( "https://.../login.html");
location. href= "https://graph.qq.com/oauth2.0/authorize?client_id=123456&response_type=code&scope=get_user_info&state="+ $scope. state+ "&redirect_uri="+ $scope. Redirect_uri_qq;
}

3) token和openId通过后台获取


二、微信登录

1)获取code

$scope. wechatLogin = function(){
//微信授权,获取code
$scope. Redirect_uri = encodeURIComponent( "https://code.html?lastUrl="+ $scope. lastUrlLink);   
location. href= "https://open.weixin.qq.com/connect/oauth2/authorize?appid=123456&redirect_uri="+ $scope. Redirect_uri+ "&response_type=code&scope=snsapi_userinfo&state="+ $scope. state_wx+ "#wechat_redirect";
}
2)其他同qq

猜你喜欢

转载自blog.csdn.net/tanqiaoxing/article/details/80709645