Is it possible to check for new posts on Facebook page (Fan Page or Personal Page)? I need to recognize new posts on page every X minutes. What are my options? Are there ways to do it without Facebook Api? And is it possible to do this with Api?
Thank you
This is possible with the Realtime API: https://developers.facebook.com/docs/graph-api/real-time-updates/v2.1
You can connect it to a Page or a User Profile. It´s much better than checking on your own with a Cron Job (for example), because Facebook will hit your callback URL on every change so you will never hit a rate limit. I´ve experienced that it is quite fast, new entries are recognized at least 30 seconds after they where changed/created, sometimes even faster.
Btw, it is not allowed without the API, that would be scraping and Facebook does not allow scraping: https://www.facebook.com/apps/site_scraping_tos_terms.php
Related
I am creating a custom Facebook Feed plugin for a custom CMS, to display the 10 latest posts of our client's public Facebook page in a fancy way, with attachments. But we have issues with very limited quota and often it goes beyond 100% and the plugin crashes.
So at my company we created a facebook app with all the necessary authorisations to use the Graph API requests and it works well. But each page load on the frontend (where there is Facebook feed present) was using like 10% of the quota. So I implemented some cache and storing the attachments locally, and I was able to get down to 2% of the quota for each page load.
But it still means that 50 visits at the same time = 100% = over limit !
So I'm kind of stuck with it, and don't know what are the best practices in this field.
The facebook official doc says that the quota on the Graph API depends on the number of app users, but we don't want (or need) to have user connection since we just want to use Graph API to display posts from public pages on our clients' websites.
Solved.
It appears that you can put a ?limit=[X] to the /[page-id]/feed API call, even though the /feed documentation page is not stating it clearly.
So my calls were fetching like... all the posts since the beginning, with all the attachments.
Adding ?limit=10 or lower to the /[page-id]/feed query solved my problem.
I have created a page for my app and I have users with facebook accounts in my system making posts to facebook. What I would like to achieve is to use my page to like these posts on facebook.
I have implemented all the functionality and it works fine programmatically, but after ~20 consequential $facebook->api("/$id/likes", "post"); calls I start to get "(#1705) There was an error during posting." exceptions. After I let it cooldown for a day these posts can be liked again.
I thought that maybe I have stressed the facebook servers, so I added sleep(few seconds) in between every api call. This allowed me to post ~300 posts before i reached same error. I still get the error an hour later.
Is there a chance I am hitting some kind of undocumented call limit?
I apologize in advance for my English.
I need to get the last tweets about a specific subject (for example.. well.. Twitter!).
Today, i use https://search.twitter.com/search.json?q=twitter to obtain that.
But as you know this is deprecated and it will shutdown. So i try to use the 1.1 API with PHP (twitteroauth) but i have this issue:
Every visitors of my website get the last twitter statuses about a subject with AJAX. If the visitor stay in my page, the twitter data will be refreshing all 10 seconds.
EDIT : Please note that i have a big amount of pages and the subject is different in every of them.
Today, the majority of my visitors are not authenticated by my website, and by twitter.
If i use the PHP-way to get data and display to my visitors, i will be rate limited if the amount of my visitors are too high. There is my questions:
There is a way to build some "anonymous" token with my secret keys to "delegate" the rate limit window to my "anonymous" user?
If not, my use of the API 1.1 are realistic? How?
And, if not again, what is your recommandation, your advice to solve this?
Thank you very much for the enlightenment!
I decided to use the streaming APIs with PHP CURL with AJAX to get my data.
I have an online blog which is custom written, by myself, with PHP. The articles & other features publish themself on a predefined date, which means that I can have 2 months of future content already lined up & writen, meaning that the site is constantly updating itself without my assistance.
Now I want to be able to update the facebook page, asociated with the blog, automatically. Is it possible to do this? All I want is for a new status to be made every time a new article is published, without me having to do it manually.
Any help would be great.
You would need to set-up a cron job (Scheduled task) to make this possible. This can be viewed in the administrative panel.
You need to assign a (cron) file that lets you check your articles publishing date and today's date.
Have you looked into facebook's api and what it could do with facebook pages. I have never tried exactly what you want to do, but from my experience it seems that is very likely. I know you can automatically request an access_token and use that to publish updates onto a pages wall.
I think the combination of these two articles is what you are looking for:
How to update a facebook page status using the facebook api
X
Update your Facebook status using PHP and Graph API
I am doing some benchmark testing on my web app and notice that the responses from Facebooks API are a lot slower than Twitters.
** For the record, I am using the twitter-async library for Twitter API integration and Facebooks own library here
With the Twitter library I can save an oAuth token & secret, I then use these to create an instance and make calls, simple. For Facebook, unless I ask for offline_permission, I must store an oAuth code and recreate an oAuth access token each time the user logs into my app.
Given the above I can:
Retrieve a Twitter users timeline in 0.02 seconds.
Get a FB oAuth Access Code in 1.16 seconds, then I can get the users details in 2.31 seconds, totalling 3.47 seconds to get the users details.
These statistics are from using functions Facebook has provided in their PHP API library. I also tried implementing my own CURL functions to get this information via a request and the results are not much better.
Is this the same kind of response times others are getting using the Facebook API?
Besides requesting offline permission and storing the permanent access token, how else can I speed up these requests, is the problem on my end or Facebooks?
Thanks,
Chris
I also have the experience the Facebook API is quite slow. I believe the facebook PHP API does not much more than wrap around CURL in the case of API calls so it makes sense that this didn't improve the speeds.
I work on a canvas page, which means for existing users, I get an access token and fb_UID as he/she comes in. At first, I did a /me graph call and sometimes a /me/friends. The first takes like 0.6 secs, the second usually a bit more. So in that case I can (to some extend) confirm your findings.
That's why I've now switched to storing important stuff locally and updating it only when needed (real time update API). Basically, I don't need any API calls during 'normal' operation.
I realize you are probably integrating FB on your own page, and perhaps use a bit more info than just name, fb-UID & friends, and that this solution is not totally answering your question. But perhaps it can still function as a small piece of the puzzle ;)
I am looking forward to other perspectives on this as well!
My application calls multiple URL's from Facebook. It does take some time :/
This is why I decided to write a function which stores the results in $_SESSION so I can use it again later, along with a timestamp to see if the data is too old.
This doesn't solve the actual problem, it just saves you having to keep fetching it.
What I like to do for end user experience, is forward them to page with a loading .gif - then have javascript request the page that actually fetches data. That way, the user remains on a loading page with a nice gif to stare at, until the next page is ready.