I've searched a lot and I see that offline_access on fb is deprecated. So, I have a website hat needs to Post a photo at the Client's wall (Post at site and Facebook too), but I want to store the login data (via token or something like that), I read here that I can't store it.
There is another way to post on wall or my client will need to Post manually on his fb?
Edit: My website is in one server, the admin is in another server, I'll make a call from admin server to site in a page that stores login information (if it's possible) and post on his wall a photo.
Thanks
Note: I've searched a lot since yesterday I didn't found anything like that, if you have a similar post with the answer please let me know.
If you have the user's access token you can use that token to perform activities on his behalf.
But the point here is- this token expires in 2 hours. But, you can extend this token upto 60 days. But after that, user needs to visit your app again to get the normal token again and you can then refresh that token to extend its validity again.
You can read Expiration and Extending Tokens section in this doc: Access Tokens
(Just a suggestion) What you can do anytime user visits your app, extend it save on your server. So, the token wont expire until and unless user didn't visited your app for 60 days. And when you are close to 60 days send him some notification.
Related
Is there any way we can post image on facebook using facebook app on access allowed user's wall on be half them/app ?
We have this to get access of user for a one time and then whatever user upload will automatically post to their post wall.
We have tried this by storing the user access token but it will expire after 2 months.
So if there is any option to generate no expire token, then it would also work.
As you already figured out, long-lived access token will expire after 60 days, which should be more than enough for most use cases.
In your case, posting to user's timeline after they take an action (and their consent) should work fine as all you need to do is request a new token. And if you use the Javascript SDK, this will be done in the background. More about this here.
I have an applicatoin that gets the birthday of the users threw a form and than it's supposed to write on there wall on there birthday.
Is this possible? even if they visit the app today and there birthday is in 200 days? Because I know the token only lasts 60 days and I want to post with there fb profile.
If I try to post the message on my fan page (where I can get a token that lasts forever) and tag them it doesn't work, because facebook doesn't allow tagging threw the api, you have any suggestions how can I achieve this?
For posting a feed on the user's wall, you can use the APP Access Token instead of the extended user token you are saving.
App Access Token
Facebook removed the offline_access permission a couple of years back:
https://developers.facebook.com/docs/roadmap/completed-changes/offline-access-removal/
"Note: The user must access your application before you're able to get a valid "authorization Code" to be able to make the server-side OAuth call again. Apps will not be able to setup a background/cron job that tries to automatically extend the expiration time, because the "authorization code" is short-lived and will have expired."
Basically you need an Authorization code to get a new token, and you can only get that if the user actively uses your app.
I have an app that allows users to manage their Facebook Pages. I have done a section on my app where users can put posts on a queue and program them to be sent on the future. For example, a page administrator is going on vacation and prepares some posts to be sent while away.
This is done with a cron task that sends the posts when the scheduled time comes. The problem is that to write on a Page I need a Page Access Token and I can't get that with a App Access Token (or can't find how to do that).
Being a cron task there is no user interaction at all so I can't get neither an User Access Token nor a Page Access Token. The user has previously authorized a Facebook App with manage_pages and publish_stream permissions.
I've tried everything to exchange an App Access Token for a Page Access Token without success.
After struggling my mind and reading (almost) all the documentation on Facebook I came with an idea: maybe I could get the users Access Token when they prepare a post to be sent on the future and save it. The problem here is what would happen if the token expires or is invalidated.
Any help would be appreciated :D
What you are trying to do need offline_access which is deprecated which is now being replaced by Extended Expiry time Access Tokens.
Read : https://developers.facebook.com/roadmap/offline-access-removal/
You can just use the sample codes given on the documentation, and get an extended access token which you can then save to a database to be retrieved when the cron hits the time to fire the post.
Sample : https://developers.facebook.com/docs/howtos/login/server-side-login/
This is my first question here, so apologies if asking something trivial - though I didn't find an answer after an hour of digging.
I have a PHP website which needs to connect with a Facebook page in the following method:
On certain triggers, the site needs to post to the page's wall as the page itself. This has to be done automatically, even if no user session is available (e.g. if someone uses the site without actually having a Facebook account).
I found solutions using extended token expiration times (offline access), but in those cases, the post will always appear as the site admin (me, in this case). However, I need the post to be written by the page. When using Facebook as the page, I have no right to request an offline access token.
Is this even possible at the moment?
You need to cache the page access token on your server and use that to make the updates - the page login is pretty well documented here: https://developers.facebook.com/docs/authentication/pages/ -
Store the access_token in your server-side code and use that token to post as the page - the page access token won't expire if you have a long-expiry access token for the page admin, unless the user stops being an admin of the page, removes the app, etc.
First of all, I'm sorry for yet another "offline_access" question, but I blame Facebook for being so vague about this. I've been reading so much (here and the official Facebook deprecation "docs") about it and the more I read, the more questions I have.
Our application uses the Facebook API to publish stories from users to their timeline. This is being done from our servers using PHP via curl.
My understanding is that accesstokens cannot be valid for more than 60 days. Does this mean that our users have to come back to our site to re-authorize everytime their token has become invalid? If so, how would services like Foursquare (who have a similar integration as we have) handle this?
Or is it possible to simply request a new token when the Facebook-API replies with a "This token has expired" message?
I think this is covered in the migration document as scenario 3 or 4 depending on your auth flow
Yes, your users need to come back at least once every 60 days in order for you to have a valid token to take actions on that user's behalf
Of course they have to come back – that’s the whole point of removing offline_access, that apps can’t go on acting forever on behalf of users who maybe don’t even notice it any more.
Or is it possible to simply request a new token when the Facebook-API replies with a "This token has expired" message?
Not without user interaction. But as far as I understand it, it should be enough to call for example FB.login via the JS SDK when the user is on your page, which will display the popup and immediately close it again if the user is logged in to FB and has still authorized your app, to get a new short-lived access_token, which you can then exchange for a long-lived one.