How does js call qq interconnection api for third-party Login

Source: Internet
Author: User
Tags openid

Qq interconnected js SDK: http://wiki.connect.qq.com/js_sdk%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E
Copy codeThe Code is as follows:
<Script type = text/javascript>

Introduce <script type = "text/javascript" in the page header"
Src = "http://qzonestyle.gtimg.cn/qzone/openapi/qc_loader.js"
Data-appid = "appid" data-redirecturi = "huidiaodizhi (with http )"
Charset = "UTF-8"> </script>

Add the following information to the body:

// Set the qq sharing button
QC. Login (
{
BtnId: "qqLoginBtn" // node id of the insert button
},
Function (reqData, opts) {// login successful

// Change the button display status based on the returned data
Var dom = document. getElementById (opts ['btnid']), _ logoutTemplate = [
// Avatar
'<Span> </span> ',
// Nickname
'<Span> {nickname} </span> ',
// Exit
'<Span> <a href = "javascript: QC. Login. signOut ();"> exit </a> </span>']
. Join ("");
Dom
& (Dom. innerHTML = QC. String
. Format (
_ LogoutTemplate,
{
Nickname: QC. String
. EscHTML (reqData. nickname), // perform xss Filtering
Figureurl: reqData. figureurl
}));
},
Function (opts) {// logout successful
Alert ("logout successful !! ");
});
// Call api authorization
QC. api ("get_info ",{
"Oauth_consumer_key": "appid" // you do not need to pass this parameter.
}). Success (function (s ){
If (QC. Login. check () {// check whether the logon is successful, and the openid and accessToken are displayed.
QC. Login. getMe (function (openId, accessToken ){
Alert (openid + "" + accessToken );
});
}
});

</Script>
<Div class = "lib_tiv shadow">
<H3 class = "logo"> QQ logon </Div>

Related Article

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.