I'm using facebook login (with facebook api) for one of my web application .
After user logged with their FB account I'm assigning secret unique code for the user in my application side .
So now I need to login to the particular user FB account automatically and post pre-defined message on that user wall when user enter that unique code (Actually users are using RFID tags sometimes they will enter that code manually)
So Is it possible to do that automatic login to the FB ?
Sounds a bit fishy ....
still:
https://developers.facebook.com/roadmap/offline-access-removal/
you can extend a users token for 60 days ...
cheers
Related
I'm using the facebook sdk 2.7 to prompt the user to login in to their facebook account and then to be able to post to their wall from our website. This works fine but each time the user visits the website they need to login again.
I do retrieve the user access token when they login. Can I use this to enable the website to always be able to post to the users wall without them having to log in to facebook each time?
You would need to use an "Extended User Token" for that, it is valid for 60 days. Btw, you are not allowed to autopost and the message always must be 100% user generated. So make sure the user approves and writes every single post.
How to create Extended User Tokens is explained in the docs:
https://developers.facebook.com/docs/facebook-login/access-tokens
http://www.devils-heaven.com/facebook-access-tokens/
I have got the APP token using https://graph.facebook.com/oauth/access_token
I have got the usser access token using https://www.facebook.com/dialog/oauth?client_id
I now what to to publish on the user FaceBook page and it appears I need to USER_ID
Where is that?
I am looking to publish using https://graph.facebook.com/[USER ID]/feed
The user id is the number or facebook user of the user where you want to post...
When you see the url from your home you see:
https://www.facebook.com/profile.php?id=4
https://www.facebook.com/zuck
In this case you can use 4 or zuck for that.
How can I get the Facebook user id when a user visits my website? I assume I need to read the Facebook cookie. How is that done?
The reason I want to grab the Facebook user id is I can then check my website's database to determine if the user has linked their Facebook account to my website and thus auto log them in.
I am assuming this is the key to how sites like Groupon are doing their auto log on.
You can't directly read the Facebook cookie, as that would violate various security features of cookies. What you're looking for instead is probably the Facebook login buttons. This should get you started: http://developers.facebook.com/docs/guides/web/#login
The authorization section of this page developers.facebook.com / docs / api contains a good description on how to perform authentication for a user agains my Facebook app. However, in my scenario I cannot get it to work the way I want. Here is how it is supposed to work:
User comes to my login page and clicks a "Sign in with Facebook" link.
User gets redirected to graph.facebook.com / oauth /authorize?[some params] and authorizes my Facebook app to access his/her data. Facebook redirects back to my site.
My site checks the Code parameter, calls Facebook to replace it for an access token, and then lets the user connect his/her account on my site with the account on Facebook. The access token is saved on the user account on my site.
The next time user arrives at my site and want to login, he/she should be able to click the same "Sign in with Facebook" link and directly get signed in with the site account (assuming he/she is still logged into Facebook)
Problem: Each time the code (from graph.facebook.com / oauth/authorize) is replaced for an access token, the token is changed. Since that token is used to look up the user in my site database, the matching failes.
My question is now: How do I solve this problem? Can the Code parameter from graph.facebook.com /oauth/authorize be saved and used over and over again to look up user? Or is there another way to do this? I really would prefer NOT using the Javascript API since it gives me lots of other troubles.
[Sorry about the links, I am a new user and not allowed to post more than one link]
Ah, I solved it: After I got the access_token I just call graph.facebook.com/me to get the id of the user. This is saved to my database. Next time I match against that id.
In my site page one text box and publish button.
When i clicked on button which is a text in text box its published on facebook as status.
For this update status user have to allow this application on facebook.
Once user allow this application whenever user clicked publish that text will update status of facebook.
and also user need not to login agian and agian to facebook. Its done internally
like update facebook status from twitter.
I am new in php.
is there any easy solution?
If somebody is looking for a working script: You can also use:
http://360percents.com/posts/php-curl-status-update-working-example/
If you only want to update the user status information you don't need to create a Facebook application. You can do it with PHP Curl library. Look at the example here - http://codesnippets.joyent.com/posts/show/1204
There is this class http://www.barattalo.it/mini-bots-php-class/ that allows you also to post on a fan page wall with a small bot, without using the facebook API.
Since the offline_access permission has been removed recently (read about that here), you'll need to get a long-lived access_token. This will let you do status updates for your users on behalf of your applications for 60 days. After 60 days, you'll have to get your users to authenticate again, since your access token would be invalidated.
You can read about that here:
https://developers.facebook.com/roadmap/offline-access-removal/