A few more specifics:
We have a good amount of fans on my restaurant's page, but we'd like to run our own website as well, with the same content (specials, etc.,) as Facebook.
With that said, we'd like to continue posting our daily specials on Facebook, as about 3,000 people see those posts and we bring in a good amount of business from there.
I have a small PHP script I've written that can pull the posts off of the wall, verify who wrote them and look for a small #hashtag to verify that I want it posted on the main page of our website.
However, periodically my access token expires and, therefore, I suspect I'm not going about this correctly.
Does anyone have a good, reliable way to read posts from a Facebook fan page?
Thank you!
You can try changing Access Token expiry time with offline_access permission.
Facebook Permissions page mentions about offline_access;
Enables your application to perform authorized requests on behalf of the user at any time. By default, most access tokens expire after a short time period to ensure applications only make requests on behalf of the user when the are actively using the application. This permission makes the access token returned by our OAuth endpoint long-lived.
Related
I'm trying to develop a little app for Facebook, and I'm facing a problem with the API.
After a few searches, I started to think the graph API doesn't allow to do what I wanna do...
Basically, I want to post automatically a message on a group wall. I have a website on which people can post their message. This community also has a Facebook group, and my point is to automatically post a copy of messages from the website, on the Facebook group. Each time a new message is submitted on the website, of course.
I know that apps and pages can’t post on a group wall by themself.
So, I considered creating a Facebook account, working like a bot, to post my messages on the group. I guess I have to get a long-lived access token for this user, and renew it manually when it expire. I don't want to have to login myself manually, but it's not a big deal if I have to renew my token time to time.
Is that even possible? Is there a better trick to do that?
I'm a bit confused by the Facebook API, and I'm sorry for this question. Even more because of the changes on the fb API...a lot of answers through the web are now deprecated. What I am looking for is a start -an idea- to be able to develop my app.
Thank you for your help :)
Yes, it is really simple:
First, You'll need access_tokenn with the offline_access permission (this way it will last for 2 months)
Then, store this access_token somewhere and do:
Post to group wall:
$fbk = new Facebook(...);
$bfk->setAccessToken($yourBotAccessToken);
$postId = $fbk->api("/$fbGroupId/feed/",'post',$message);
You can even post replies to the first post:
$fbk->api('/'.$postid.'/comments/','post',$reply);
I searched in Stack Overflow, Google, etc, but I can't figure out how to show my stuff from my Facebook on my website. I tried some solutions and each one prompted the login dialog and visitors had to log in and accept my application (I've created one to test).
Many answers here were too generic, I didn't understand them that is why I'm asking.
I want something that would let my website "log in" to Facebook and show my status or photos to visitors without them needing to accept an app or log in into Facebook with their account.
I tried a facebook-php-sdk example with my AppID and AppSecret and it asked me to log in.
Also, github.com/facebook doesn't have an SDK for Python similar to facebook-php-sdk
You could write a script (eg. using the FB PHP SDK) that uses a long-lived access token to fetch your FB data and then store the data in your backend database (or other store for your website). To Facebook, your script will look like an app and your machine will be the only 'user' of that app. Note, long-lived access tokens are good for 60 days max. You could also try using an App Access Token to fetch basic info. App Access Tokens don't expire.
This might not be exactly what you are looking for since you posted this with the php and python tag, but it might solve your problem.
If you're website is powered by the wordpress engine you can use If-this-then-that : https://ifttt.com/
It basically allows you to create "recipes" with something like:
if new status on Facebook then create post on wordpress
The post will not require others to log in to Facebook.
This is without writing a single line of code only a couple of mouse clicks. So I'm not sure if this satisfies your needs.
I have a contest App. And many users have installed the app. I have stored the offline_access tokens of these users. I want to send a message to all users of app at the end of contest. What is the best way to do it. Because when I do it in a while loop the page never loads and browser just shows loading animation gif on tab.
You don't even need the user access tokens to accomplish something similar to what you're trying to do.
First off, mass-wall posting is both a violation of the Facebook Platform Policies (specifically IV.2, IV.3), but it's also really spammy and users will react negatively, probably blocking your app and ultimately it may get banned from Facebook. So don't do that.
Instead, you should utilise the intended social channel for notifying users of new content, App to user Requests.
This is pretty simple to do, as per the Graph API docs for apprequests you just make the following API call:
https://graph.facebook.com/USERID/apprequests?app_access_token=APPTOKEN
Where USERID is each user's Facebook ID and APPTOKEN is always your applications unique access token (see the documentation here if you do not know how to obtain one of those). You will also need to include parameters such as message, which you can read more about in the docs.
Is there any way to post on user's wall as the Application and not as user?
It's hard to provide a definitive answer without some more context as to what sort of post you want to do, but the answer is probably no.
We dont provide a a mechanism for pages or applications to write on a users wall directly.
As a Page, you can post on your wall, and the messages you write will be shown to a subset of the users who have liked your page in the news feed.
As an application you can use stream.publish to post on the users wall/timeline with an application attribution. But it's not as the application per se.
With Timeline Apps you can use the Open Graph to publish actions the user has taken with your app, like Spotify does. So you're posting what the user has done with your app, rather than posting as the user.
HTH
I've been building a web app that uses facebook integration for easier registration/login and notifications for the users. However, for the notifications I want to be able to post to a users facebook wall when something happens on our site.
Really I see two possible problems with doing this. First being that the user will most likely not be logged in to our website when the notification needs to happen. Second I have not found a way to post to the feed using any identity other than the current logged in user.
So to reiterate exactly what I'm trying to do. When some action takes place on my site involving Bob, I want the websites application to post on Bobs wall notifying him of the action as if the application is one of Bobs friends. From some of the things I've seen while researching this, it seems as if facebook might not treat applications like users and I might have to go through a page to accomplish what I want. But really I'm ok with that.
What you need to do is to ask for the offline_access permission. Then you can store their graph id property after they login/authorize to your site's database. Then you just post to that graph id instead of instead of /me. In your case you would then POST a request to the "$user_graph_id/feed" endpoint with whatever parameters you usually have.