JS How to call the QQ Interconnect API to achieve Third-party login _javascript skills

Source: Internet
Author: User
Tags openid
QQ Interconnect JS sdk:http://wiki.connect.qq.com/js_sdk%e4%bd%bf%e7%94%a8%e8%af%b4%e6%98%8e
Copy Code code as follows:

<script type=text/javascript>

Introducing in Page header: <script type= "Text/javascript"
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 QQ Share button
Qc. Login (
{
Btnid: The node ID of the "qqloginbtn"//Insert button
},
function (Reqdata, opts) {//Login successful

Replace the button display state method 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),//XSS filtering
Figureurl:reqData.figureurl
}));
},
Function (opts) {//Logout succeeded
Alert ("Logout successful!!") ");
});
Invoke API Authorization
Qc.api ("Get_info", {
"Oauth_consumer_key": "AppID"//This can not be passed
}). Success (function (s) {
if (QC. Login.check ()) {//Check for successful login and eject OpenID and Accesstoken
Qc. Login.getme (function (openId, Accesstoken) {
Alert (openid+ "" +accesstoken);
});
}
});

</script>
<div class= "Lib_tiv Shadow" >

</div>

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.