I'm trying to do server-side posting of facebook and twitter posts. So, you click a button: if you're not connected it allows you to connect and opens a dialog overlay to allow you to post a facebook/twitter post; if you are connected it just opens the overlay. Facebook works because I can get all the oAuth keys easily client-side and then pass them to the server. How do I do this in Twitter?
(PS: this is a fully AJAX site so I can't count on page refreshes)
In facebook I do this:
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' });
}
});
How do I get the auth token, maybe using twitter @anywhere code?
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();
}
});
}
Thank you for your help!