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按钮

  
  


2)获取code

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

wap接入微信、qq第三方登录_第1张图片

$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

你可能感兴趣的:(javascript)