推特第三方登錄


//引入Twitter
window.twttr = (function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0],
t = window.twttr || {};
if (d.getElementById(id)) return t;
js = d.createElement(s);
js.id = id;
js.src = "https://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);

t._e = [];
t.ready = function (f) {
t._e.push(f);
};

return t;
}(document, "script", "twitter-wjs"));

// 初始化Twitter登錄並定義login_twitter登錄方法。

var log = console.log;
hello.init(
{ 'twitter': '***************' }, //App_key
{ oauth_proxy: 'https://auth-server.herokuapp.com/proxy' });
function login_twitter(network) { //登錄方法,並將twitter 作為參數傳入
// Twitter instance
var twitter = hello(network);
// Login
twitter.login().then(function (r) {
// Get Profile
return twitter.api('/me');
}, log).then(function (p) {

console.dir(p);
//已獲取用戶信息,在此處理

var response = { 'id': p.id, 'first_name': p.name, 'last_name': p.last_name, 'picture': p.thumbnail, 'link': 'https://twitter.com/' + p.screen_name, 'login_type': 'twitter' };
console.dir(response);

}, log);
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM