QQ login to get a fixed value, online, etc., QQ Color QQ login
Ret: 0
Msg:
Nickname: Wi_H
Gender: Female
Figureurl: http://qzapp.qlogo.cn/qzapp/100330589/##/30
Is_yellow_vip: 0
Vip: 0
Yellow_vip_level: 0
Level: 0
Is_yellow_year_vip: 0
The preceding values are returned by logon. they are not fixed.
Which values are fixed during QQ login? Used as the account ID.
In other words, the OpenID is fixed. how can I call it?
Reply to discussion (solution)
Generally, the account ID is automatically increased to generate an ID even if it is an out-of-site authorization.
Username generally uses nickname. if you repeatedly add a number or the like for modification, you can directly ask everyone to re-enter the user name.
Openid. these other tables are saved or directly saved to the user table.
Generally, the account ID is automatically increased to generate an ID even if it is an out-of-site authorization.
Username generally uses nickname. if you repeatedly add a number or the like for modification, you can directly ask everyone to re-enter the user name.
Openid. these other tables are saved or directly saved to the user table.
Sorry, wrong! Yes [username]
If you use [nickname] to create an account, do you need to register a new account if the user changes his/her name?
Officially, [openid] is fixed, but I cannot call it.
Require_once (".. /login/qqConnectAPI. php "); // get API $ qc = new QC (); $ userdata = $ qc-> get_user_info (); // The member returns the user information $ userdata ["gender"]; $ userdata ["nickname"];
You can only call the preceding sections.
Generally, the account ID is automatically increased to generate an ID even if it is an out-of-site authorization.
Username generally uses nickname. if you repeatedly add a number or the like for modification, you can directly ask everyone to re-enter the user name.
Openid. these other tables are saved or directly saved to the user table.
Sorry, wrong! Yes [username]
If you use [nickname] to create an account, do you need to register a new account if the user changes his/her name?
Officially, [openid] is fixed, but I cannot call it.
Require_once (".. /login/qqConnectAPI. php "); // get API $ qc = new QC (); $ userdata = $ qc-> get_user_info (); // The member returns the user information $ userdata ["gender"]; $ userdata ["nickname"];
You can only call the preceding sections.
1. even if the user who logs on to your website using QQ has changed the QQ nickname, the logon to your website will not be affected because the logon is not determined based on the nickname.
2. let's take a look at the openid that will be provided during the authorization process and be saved to the database. if you still cannot find this step, I will help you to check our website and log on to it via QQ.
Generally, the account ID is automatically increased to generate an ID even if it is an out-of-site authorization.
Username generally uses nickname. if you repeatedly add a number or the like for modification, you can directly ask everyone to re-enter the user name.
Openid. these other tables are saved or directly saved to the user table.
Sorry, wrong! Yes [username]
If you use [nickname] to create an account, do you need to register a new account if the user changes his/her name?
Officially, [openid] is fixed, but I cannot call it.
Require_once (".. /login/qqConnectAPI. php "); // get API $ qc = new QC (); $ userdata = $ qc-> get_user_info (); // The member returns the user information $ userdata ["gender"]; $ userdata ["nickname"];
You can only call the preceding sections.
1. even if the user who logs on to your website using QQ has changed the QQ nickname, the logon to your website will not be affected because the logon is not determined based on the nickname.
2. let's take a look at the openid that will be provided during the authorization process and be saved to the database. if you still cannot find this step, I will help you to check our website and log on to it via QQ.
Hello, my buckle: 847149513
Or do you want to leave your QQ line?
QQ accounts are shy and cannot be easily exposed.
Code for you
As described in the api documentation, first obtain access_token with appid appkey and then obtain the openid based on this
The key is that you need to understand the api documentation.
The code is simple and easy to understand.
Function qq_callback () {// debug // print_r ($ _ REQUEST); // print_r ($ _ SESSION ); if ($ _ REQUEST ['state'] ==$ _ SESSION ['state']) // csrf {$ token_url =" https://graph.qq.com/oauth2.0/token?grant_type=authorization_code& ". "Client_id = ". $ _ SESSION ["appid"]. "& redirect_uri = ". urlencode ($ _ SESSION ["callback"]). "& client_secret = ". $ _ SESSION ["appkey"]. "& code = ". $ _ REQUEST ["code"]; $ response = get_url_contents ($ token_url); if (strpos ($ response, "callback ")! = False) {$ lpos = strpos ($ response, "("); $ rpos = strrpos ($ response, ")"); $ response = substr ($ response, $ lpos + 1, $ rpos-$ lpos-1); $ msg = json_decode ($ response); if (isset ($ msg-> error) {echo "error: ". $ msg-> error; echo "msg :". $ msg-> error_description; exit; }}$ params = array (); parse_str ($ response, $ params); // debug // print_r ($ params ); // set access token to session $ _ SESSION ["access_token"] = $ params ["access_token"];} else {echo ("The state does not match. you may be a victim of CSRF. ") ;}} function get_openid () {$ graph_url =" https://graph.qq.com/oauth2.0/me?access_token= ". $ _ SESSION ['Access _ token']; $ str = get_url_contents ($ graph_url); if (strpos ($ str," callback ")! = False) {$ lpos = strpos ($ str, "("); $ rpos = strrpos ($ str, ")"); $ str = substr ($ str, $ lpos + 1, $ rpos-$ lpos-1);} $ user = json_decode ($ str); if (isset ($ user-> error) {echo "error: ". $ user-> error; echo "msg :". $ user-> error_description; exit;} // debug // echo ("Hello ". $ user-> openid); // set openid to session $ _ SESSION ["openid"] = $ user-> openid;} // callback address after successful QQ login, mainly save access tokenqq_callback (); // obtain the user ID idget_openid ();
QQ accounts are shy and cannot be easily exposed.
Code for you
As described in the api documentation, first obtain access_token with appid appkey and then obtain the openid based on this
The key is that you need to understand the api documentation.
The code is simple and easy to understand.
Function qq_callback () {// debug // print_r ($ _ REQUEST); // print_r ($ _ SESSION ); if ($ _ REQUEST ['state'] ==$ _ SESSION ['state']) // csrf {$ token_url =" https://graph.qq.com/oauth2.0/token?grant_type=authorization_code& ". "Client_id = ". $ _ SESSION ["appid"]. "& redirect_uri = ". urlencode ($ _ SESSION ["callback"]). "& client_secret = ". $ _ SESSION ["appkey"]. "& code = ". $ _ REQUEST ["code"]; $ response = get_url_contents ($ token_url); if (strpos ($ response, "callback ")! = False) {$ lpos = strpos ($ response, "("); $ rpos = strrpos ($ response, ")"); $ response = substr ($ response, $ lpos + 1, $ rpos-$ lpos-1); $ msg = json_decode ($ response); if (isset ($ msg-> error) {echo "error: ". $ msg-> error; echo "msg :". $ msg-> error_description; exit; }}$ params = array (); parse_str ($ response, $ params); // debug // print_r ($ params ); // set access token to session $ _ SESSION ["access_token"] = $ params ["access_token"];} else {echo ("The state does not match. you may be a victim of CSRF. ") ;}} function get_openid () {$ graph_url =" https://graph.qq.com/oauth2.0/me?access_token= ". $ _ SESSION ['Access _ token']; $ str = get_url_contents ($ graph_url); if (strpos ($ str," callback ")! = False) {$ lpos = strpos ($ str, "("); $ rpos = strrpos ($ str, ")"); $ str = substr ($ str, $ lpos + 1, $ rpos-$ lpos-1);} $ user = json_decode ($ str); if (isset ($ user-> error) {echo "error: ". $ user-> error; echo "msg :". $ user-> error_description; exit;} // debug // echo ("Hello ". $ user-> openid); // set openid to session $ _ SESSION ["openid"] = $ user-> openid;} // callback address after successful QQ login, mainly save access tokenqq_callback (); // obtain the user ID idget_openid ();
I am using the official SDK, http://wiki.connect.qq.com/sdk%E4%B8%8B%E8%BD%BD
Have you read every file in the downloaded SDK folder?
In connect2.0/API/class/Oauth. class. php, there are two methods: qq_callback () get_openid (), row 53, row 94.
Before returning openid in row 119, I saved it to the database and didn't get the openid?
The authorization process API documentation sdk file looks nice. I think it is easy to further communicate with you if you have specific questions. The key is to figure out this process. this is the development process.
Have you read every file in the downloaded SDK folder?
In connect2.0/API/class/Oauth. class. php, there are two methods: qq_callback () get_openid (), row 53, row 94.
Before returning openid in row 119, I saved it to the database and didn't get the openid?
The authorization process API documentation sdk file looks nice. I think it is easy to further communicate with you if you have specific questions. The key is to figure out this process. this is the development process.
Thank you! in fact, I called it out long ago! But an error occurred! The error openid,
Details determine success or failure.
Just call it out.