FacebookやTwitterの投稿をサーバー側で投稿しようとしています。つまり、ボタンをクリックします。接続していない場合は、接続を許可し、ダイアログ オーバーレイを開いて、Facebook/Twitter の投稿を投稿できるようにします。接続されている場合は、オーバーレイが開きます。Facebook が機能するのは、すべての oAuth キーをクライアント側で簡単に取得してサーバーに渡すことができるためです。Twitterでこれを行うにはどうすればよいですか?
(PS: これは完全な AJAX サイトなので、ページの更新は期待できません)
フェイスブックで私はこれを行います:
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();
}
});
}
ご協力ありがとうございました!