Connect an existing user account twitter permanently - php

I want to be able to connect an existing user account to his twitter account.
I want to give the option for the user to connect his twitter account. After that is done once, I would like to be able to auto-tweet to his account.
How can I achieve this?

When the user logs in using their twitter credentials you retain an oAuth token that will allow you to call twitter APIs with the permissions the user granted when the token was generated.
This token can be revoked by the user at any time.
The twitter site has loads of great documentation on this area:
https://dev.twitter.com/docs/auth/obtaining-access-tokens

Related

Facebook PHP API and token expiration

I have PHP site. User can come on that site and connect with Facebook. When user is connected I get user id and access token and store to database. I used that access token to post some things (text, photos, and links on users FB).
Now, I see that access token is expiring after 60 days (extended token) and after that I need to prompt user to connect to Facebook again.
Problem is that my site need to post couple of messages which user wrote after he pass. And user can connect to Facebook for example 1. Sep 2013 and can pass after couple of years.
Is there any way how can I post that messages on that user's Facebook account, without prompting user to connect to Facebook again (of course if user not deny app on Facebook account before that) even token is expired.
Twitter and YouTube has unexpiring tokens which allow me to post on that social networks posts in couple of years (of course if user not deny my app on theirs accounts on twitter and YouTube).
Thanks
For simply posting to the user's wall; you can use the APP ACCESS TOKEN (APP-ID|APP-SECRET) for that.

How to create re-authentication in Twitter?

I have a query that I want to set re-authentication in my website like this:
If i registered once in my website and link my account with twitter then next time I logged into the website I would not need to log in with twitter. It will be automatically connected with twitter.
You'll still need to authenticate with twitter each time, but you can save the users oauthtoken and oauthtoken secret to a mySQL database so you don't have to ask the user to authenticate manually. The keys, if you will, never expire. Your apps authentication can however be revoked by the twitter user. Here's a helpful tutorial on getting setup from scratch. Some of the first steps have changed, but "Registering users" section will be helpful to you.

How can I access multiple API´s (Facebook and Twitter) on one user?

I am always reading about Facebook and Twitter logins for someones website.
The integration using one of theses services is okay, but my questions is how can I access both API´s for one user.
Example:
User is logged in on my website (active session). Now he somehow has to grant me access to his user details etc. on facebook AND twitter. How do I realize that? I don´t want him/her to type in his facebook or twitter credentials everytime he logs in to get his access token (oAuth).
How do I get my own oAuth user access token after using my websites login, so I can interact with Facebook and Twitter´s API.
Is this correct?
Thank you very much, if you can help me.
Facebook
When someone logs into the Facebook account, they stay logged in until they actively log out.
The way to test for this is:
FB.getLoginStatus(function(response){
if response.status === 'connected'{
// The user is logged in
var access_token = response.authResponse.accessToken;
// Do whatever you need to do
} else {
// Get the user to log in
}
});
See here for more details:
https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/
Twitter
The process is a little more complex for Twitter, but if you only want to display tweets, consider Web Intents.
Otherwise, follow these steps:
https://dev.twitter.com/docs/auth/3-legged-authorization
Both platforms have the ability to check whether or not the user is logged in first, so you shouldn't have to worry about someone having to log in every time they use your site. However, you cannot use the same oAuth token on both sites - you must get a separate one for each.
Each individual API will need a popup to authenticate, which will redirect to the appropriate api for authorisation, and then once you have the token after the authorisation redirects back to your popup.
You will then end up with a token that you can pass back to the calling page "window.opener" and store the token for that api in a Javascript variable by alling a Javascript funcation on the main page.
window.opener.getInstagramData("self", oauth_token);
Each authentication needs to have its own token and needs to be a button that the user should click on.
I am using this method to get Facebook, Twitter, LinkedIn Foursquare and GooglePlus account info.
Hope this helps.

Facebook Login by sending User Name and Password from my Database Table

I want to login to facebook account from my website,
User Name & Password are already stored in my Database and when user is login to my website at that time using that user name & password he is automatic login to o facebook account and fetch some detail and display.
Is it Possible? If yes then how?
Using PHP.
Facebook uses OAuth that allows your website to interact with facebook and if the user is not logged in, they have the option of logging in. You have to program OAuth to ask for permissions to access the users basic profile and extended permissions depending on what you want to pull. Permissions only have to be given once and are managed via facebook account settings. At any time the user can reject access to your website/app. I would suggest to start looking here: http://developers.facebook.com/docs/reference/php/ and http://developers.facebook.com/docs/reference/api/

Use twitter api to log user out of Twitter

I'm building an app where I want to allow users to be able to set up more than one twitter account with my application, so it would be best for me to be able to log them out of twitter before they add a new account so that they can enter their information for their new account and not just be forwarded back to my site because the user already has access with the account that they're logged in with. Others have said that it is not possible to log out a user with the twitter api, but I know that it is because hootsuite.com will log me out of my twitter account whenever I try to add a new one. Thanks!
ANSWERED
I found the solution. You cannot log the user out, but you can force them to log in to authorize your app. You just add the &force_login=true parameter to the end of your authorize url and you're good to go!
http://code.google.com/p/twitter-api/issues/detail?id=469
I found the solution. You cannot log the user out, but you can force them to log in to authorize your app. You just add the &force_login=true parameter to the end of your authorize url and you're good to go!
http://code.google.com/p/twitter-api/issues/detail?id=469

Categories