Micro-letter, micro-Bo, QQ, this is now the most mobile phone APP, we do not have to make products with them, for login, I think who do not want how many account password, can not remember!
In order to increase the user experience, users can quickly register the login, the third party account to sign up for registration of the need to be born
1. Micro-letter
1 Micro-Letter login is also the most deceptive, the need to spend 300 of the ocean to become a developer account, no way who let the micro-letter user group is big, so also have to recognize; then login site background to create site applications, fill in the authorization callback domain (login site domain name) can only fill
Application Address: Https://open.weixin.qq.com/cgi-bin/index?t=home/index&lang=zh_CN
2 View the interface provided by the micro-letter, write Java code
public void wx () {try {response.sendredirect ("https://open.weixin.qq.com/connect/qrconnect?appid=" + sharelogind Ict. Weixinkey.getstate () + "&redirect_uri=" + Urlencoder.encode (ShareLoginDict.WEIXINURL.getState ()) + "&res
Ponse_type=code&scope=snsapi_login&state=66666#wechat_redirect ");
catch (IOException e) {//TODO auto-generated catch block E.printstacktrace ();
@Override public result userwx (String return_code) {result result = new result ();
Map<string, object> token = (map<string, object>) weixinapi. GetToken (Return_code); if (token!= null && token.get ("Access_token")!= null) {map<string, object> user = (map<string, objec
t>) Weixinapi. Getwxuser (Token.get ("Access_token"). ToString (), Token.get ("OpenID"). ToString ());
if (user!= null) {Result.addmodel ("OpenID", User.get ("OpenID"));
Result.addmodel ("nickname", User.get ("nickname")); Result.addmodel ("Headimgurl", User.get ("HeadiMgurl "));
Result.addmodel ("Data", "data_success");
}else{Result.addmodel ("Data", "Data_null");
}}else{Result.addmodel ("Data", "Data_null");
return result;
}
When the user is logged in by a micro-letter, call the micro-interface to obtain the user interface to return the micro-client OpenID, nickname, Avatar; then deposit this information in the browser's cookie, and when the user browses other information, identify if the user is logged in with a micro-letter, The interceptor directly retrieves the user's information from the cookie to display the nickname and Avatar, and at the same time determines whether the OpenID is bound to the user in the database, if no binding prompts the user to register.
2, QQ Login
1) QQ Interconnection creation Application
Access QQ before login, the site needs to apply first, to obtain the corresponding AppID and Appkey, to ensure that the following process can be correct for the site and users to authenticate and authorize.
Applications for AppID and Appkey
AppID: Unique identification of the application. During the OAuth2.0 authentication process, the AppID value is the Oauth_consumer_key value.
Appkey:appid the corresponding key to verify the legality of the application when accessing user resources. During the OAuth2.0 authentication process, the Appkey value is the Oauth_consumer_secret value.
Application Address: http://connect.qq.com/intro/login/
2 to see the interface provided by QQ, write Java code
public void QQ () {try {response.sendredirect ("https://graph.qq.com/oauth2.0/authorize?response_type=code& Client_id= "+ ShareLoginDict.QQKEY.getState () +" &redirect_uri= "+ ShareLoginDict.QQURL.getState () +" &SC
Ope=get_user_info ");
catch (IOException e) {//TODO auto-generated catch block E.printstacktrace ();
@Override public result Userqq (String return_code) {result result = new result ();
Map<string, object> token = (map<string, object>) qqapi. GetToken (Return_code); if (token!= null && token.get ("Access_token")!= null) {map<string, object> Tokenme = (map<string, Ob
ject>) Qqapi. Gettokenmeopenid (Token.get ("Access_token"). toString ()); if (Tokenme!= null && tokenme.get ("OpenID")!= null) {map<string, object> user = (map<string, object& gt;)
Qqapi. Getqquser (Token.get ("Access_token"). ToString (), Tokenme.get ("OpenID"). ToString ()); if (user!= null) {Result.addmodel ("OPenid ", Tokenme.get (" OpenID "));
Result.addmodel ("nickname", User.get ("nickname"));
Result.addmodel ("Figureurl", User.get ("Figureurl"));
Result.addmodel ("Data", "data_success");
}else{Result.addmodel ("Data", "Data_null");
}}else{Result.addmodel ("Data", "Data_null");
}}else{Result.addmodel ("Data", "Data_null");
return result;
}
When the user login through QQ, call QQ interface to get the user interface back to the QQ end of OpenID, nickname, Avatar; then store this information in a cookie in the browser, and when the user browses other information, identify if the user is logged in with a micro-letter, The interceptor directly retrieves the user's information from the cookie to display the nickname and Avatar, and at the same time determines whether the OpenID is bound to the user in the database, if no binding prompts the user to register.
3 Micro-Blog Login
1 Micro Blog Creation application
Application Address: Http://open.weibo.com/authentication
2 View the interface provided by Weibo, write Java code
public void WB () {try {response.sendredirect ("https://api.weibo.com/oauth2/authorize?client_id=" + sharelogindict .
Weibokey.getstate () + "&redirect_uri=" + ShareLoginDict.WEIBOURL.getState () + "&response_type=code");
catch (IOException e) {//TODO auto-generated catch block E.printstacktrace ();
@Override Public result USERWB (string return_url, string return_code) {result result = new result ();
Map<string, object> token = (map<string, object>) Weiboapi.gettoken (Return_url, Return_code); if (token!= null && token.get ("Access_token")!= null) {map<string, object> user = (map<string, objec
t>) Weiboapi. Getwbuser (Token.get ("Access_token"). ToString (), Token.get ("UID"). ToString ());
if (user!= null) {Result.addmodel ("name", User.get ("Screen_name"));
Result.addmodel ("Pic", User.get ("Avatar_large"));
Result.addmodel ("Idstr", User.get ("Idstr"));
Result.addmodel ("Data", "data_success");
}else{ Result.addmodel ("Data", "Data_null");
}}else{Result.addmodel ("Data", "Data_null");
return result;
}
When the user is logged in via Weibo, call the microblogging interface to get the user interface to return the IDSTR, nickname, Avatar of the microblog, and then store this information in a cookie in the browser, and when the user browses other information, identify if the user is logged in with a micro-letter, The interceptor directly retrieves the user's information from the cookie to display the nickname and Avatar, and at the same time determines whether the OpenID is bound to the user in the database, if no binding prompts the user to register.
Thank you for reading, I hope to help you, thank you for your support for this site!