QQ login to get fixed value, online and other 、、、

Source: Internet
Author: User
Tags oauth openid
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 above is the value returned by the login, seemingly is not fixed.

What are the values returned in the QQ login that are fixed? Used as the ID of the account.

If OpenID is fixed, how do I invoke it?





Reply to discussion (solution)

The ID of the account is generally automatically generated even if the ID is authorized to come in from outside the station

Username General use Nickname if repeat automatically add a number and so on to yourself or directly ask everyone to re-enter the user name

OpenID these are saved in a different form or stored directly in the user's table.

The ID of the account is generally automatically generated even if the ID is authorized to come in from outside the station

Username General use Nickname if repeat automatically add a number and so on to yourself or directly ask everyone to re-enter the user name

OpenID these are saved in a different form or stored directly in the user's table.

Sorry, that's wrong! It's "username."
If you use "nickname" as the account, when the user modified their own name, it will not be able to log in and need to re-register it?

The official said "OpenID" is fixed, but I can't call it.

Require_once (".. /login/qqconnectapi.php ");//Get API$QC = new QC (); $userdata = $qc->get_user_info ();//Member Return user profile $userdata[" gender "];$ userdata["nickname"];


Only a few parts of the above can be called.


The ID of the account is generally automatically generated even if the ID is authorized to come in from outside the station

Username General use Nickname if repeat automatically add a number and so on to yourself or directly ask everyone to re-enter the user name

OpenID these are saved in a different form or stored directly in the user's table.

Sorry, that's wrong! It's "username."
If you use "nickname" as the account, when the user modified their own name, it will not be able to log in and need to re-register it?

The official said "OpenID" is fixed, but I can't call it.

Require_once (".. /login/qqconnectapi.php ");//Get API$QC = new QC (); $userdata = $qc->get_user_info ();//Member Return user profile $userdata[" gender "];$ userdata["nickname"];


Only a few parts of the above can be called.

1. Users who log on to your website with QQ will not be affected by their nickname, even if they have modified their QQ nickname.

2. You first look at the authorization process authorization process will give you OpenID, catch into the database. If you still can not find this afternoon I help you to see our website also use QQ login.



The ID of the account is generally automatically generated even if the ID is authorized to come in from outside the station

Username General use Nickname if repeat automatically add a number and so on to yourself or directly ask everyone to re-enter the user name

OpenID these are saved in a different form or stored directly in the user's table.

Sorry, that's wrong! It's "username."
If you use "nickname" as the account, when the user modified their own name, it will not be able to log in and need to re-register it?

The official said "OpenID" is fixed, but I can't call it.

Require_once (".. /login/qqconnectapi.php ");//Get API$QC = new QC (); $userdata = $qc->get_user_info ();//Member Return user profile $userdata[" gender "];$ userdata["nickname"];


Only a few parts of the above can be called.

1. Users who log on to your website with QQ will not be affected by their nickname, even if they have modified their QQ nickname.

2. You first look at the authorization process authorization process will give you OpenID, catch into the database. If you still can not find this afternoon I help you to see our website also use QQ login.


Hello, my buckle: 847149513

Or would you please leave your QQ line

QQ number good shy can not be easily exposed AH
give you the code bar
as described in the API documentation first use AppID Appkey and so get the Access_token again based on this get OpenID
The point is you have to read the API documentation .... No one else can help you understand this. 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_ty pe=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 is not match. 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;} QQ Login Successful callback address, mainly save access tokenqq_callback ();//Get user identification Idget_openid ();

QQ number is very shy can not easily expose AH
I'll give you the code.
Just like the API documentation, get Access_token with AppID Appkey and get OpenID based on this.
The point is you have to read the API documentation .... There's no way anyone can help you understand that.

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_ty pe=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 is not match. 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;} QQ Login Successful callback address, mainly save access tokenqq_callback ();//Get user identification Idget_openid ();


I'm using the official SDK 、、、 Http://wiki.connect.qq.com/sdk%E4%B8%8B%E8%BD%BD.

Downloaded the SDK folder every file read it?

There are two methods in the connect2.0/api/class/oauth.class.php. Qq_callback () Get_openid () 53 Rows 94 rows

Say a stupid way. 119 line return to OpenID before you put it in the database did you get OpenID?

Authorization Process API Documentation SDK files take a good look. There is no specific understanding of the further communication I think it is more understandable. The key is to figure out the process. This is the process of development.

Downloaded the SDK folder every file read it?

There are two methods in the connect2.0/api/class/oauth.class.php. Qq_callback () Get_openid () 53 Rows 94 rows

Say a stupid way. 119 line return to OpenID before you put it in the database did you get OpenID?

Authorization Process API Documentation SDK files take a good look. There is no specific understanding of the further communication I think it is more understandable. The key is to figure out the process. This is the process of development.

Thank you, in fact, I have already transferred out! It's just a mistake! Thought it was the wrong OpenID,
Details determine success or failure

Just pull it up, okay?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.