Javascript 对于Twitter:如何获得用户的oauth_访问权_令牌客户端,如facebook,用于服务器端集成
我正在尝试在服务器端发布facebook和twitter帖子。因此,你点击一个按钮:如果你没有连接,它允许你连接并打开一个对话框覆盖,允许你发布facebook/twitter帖子;如果您已连接,它只会打开覆盖。Facebook之所以有效,是因为我可以在客户端轻松获取所有oAuth密钥,然后将它们传递给服务器。我如何在Twitter上做到这一点? PS:这是一个完全AJAX的网站,所以我不能指望页面刷新 在facebook上,我这样做:Javascript 对于Twitter:如何获得用户的oauth_访问权_令牌客户端,如facebook,用于服务器端集成,javascript,facebook,twitter,oauth,twitter-anywhere,Javascript,Facebook,Twitter,Oauth,Twitter Anywhere,我正在尝试在服务器端发布facebook和twitter帖子。因此,你点击一个按钮:如果你没有连接,它允许你连接并打开一个对话框覆盖,允许你发布facebook/twitter帖子;如果您已连接,它只会打开覆盖。Facebook之所以有效,是因为我可以在客户端轻松获取所有oAuth密钥,然后将它们传递给服务器。我如何在Twitter上做到这一点? PS:这是一个完全AJAX的网站,所以我不能指望页面刷新 在facebook上,我这样做: if (FB) {
if (FB) {
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
$.getJSON(window.page.services + "StoreAuthToken", { type: "facebook", socialId: response.authResponse.userID, authId: response.authResponse.accessToken, expiresInSeconds: response.authResponse.expiresIn }, null);
window.dialogs.loadFacebookOverlay({ href: href, image: image, description: description, socialId: response.authResponse.userID });
} else {
FB.login(function(response) {
if (response.status === 'connected') {
$.getJSON(window.page.services + "StoreAuthToken", { type: "facebook", socialId: response.authResponse.userID, authId: response.authResponse.accessToken, expiresInSeconds: response.authResponse.expiresIn }, null);
window.dialogs.loadFacebookOverlay({ href: href, image: image, description: description, socialId: response.authResponse.userID });
} else { /* user cancled */ }
}, { scope: 'share_item' });
}
});
如何获取身份验证令牌,可能使用twitter@anywhere代码
if (twttr) {
twttr.anywhere(function(T) {
if (T.isConnected()) {
/* how do I get the auth token here? */
window.dialogs.loadTwitter({ href: href, image: image, description: description });
} else {
/* a pop-up is blocked - any way to allow it? */
T.signIn();
}
});
}
谢谢你的帮助 这里还问:我取得了一些进展。现在我只需要auth令牌,这样我就可以做服务器端的事情了。我调用像$window.bindload这样的anywhere函数,functione{if twttr{twttr.anywhere functiont{window.twitter=T;};};然后我可以在弹出窗口不被阻止的情况下呼叫登录。问题是,当我调用window.twitter.bindauthComplete、functione时,用户{/*用户数据没有auth令牌*/};现在,既然我已连接,如何获取身份验证令牌?