Requesting posts of a facebook group - facebook

I am looking to create a product that retrieves the posts of a public facebook group (viewable to non-members) and analyse that data based on (from necessary to useful) posts (as strings to be processed), like count, different reaction count and possible geotag data. I am confused by the process of application, as I cannot use the group api without already having an approved app and such - is there a way to retrieve and work on data in python/java/js without actually creating an app, for testing purposes?

Related

How to Avoid Facebook Graph API Limit with million of users

I have a WordPress webpage with posts retrieving from a public Facebook page. The FB page is not mine. However the problem is that I have millions of visitors on my Web page and every time a user visits the web page it make an API call to FB Page. Since facebook allows only a limited number of API calls in a time frame, My limit reaches instantly with such a huge number of visitors. Is there any solution to this problem. an idea in my mind is:
1. retrieve posts from Facebook and store them locally and display them every time a user visits. Is it possible? If Yes where to start ?
Or can we get more API calls by paying facebook or things like that. I am ready to pay as far as my API calls can be made sufficient for my needs.
I am open to any solution and would be very thankful for any help to resolve the problem.
There are several possible solutions to this problem
Storing responses in database
You can add a middlepoint to your requests to Facebook API using your application. This would mean that you would have a database table which stores Facebook-related information, possibly along with a lifecycle time, like:
facebook_data(user_id, lifecycle_time, ...)
Whenever you would theoretically need to send a request to Facebook API, you can check the database table to see whether the user already has a record in that table and whether it is still valid. If so, give this data to the user. If not, send an API request to Facebook and store the response in this table.
Storing responses in localStorage/memory/file
You can also store Facebook-related data in the localStorage of the web browser of the memory of an app or a file, or even a local database specific for each user. This would prevent a lot of communication and server load your app is issuing on your server(s).
Queueing user requests to be sent
If the Facebook-related data is not very urgent to your users, you can queue requests to be sent and send a single request instead of a request for each user's each visit. You can do this via a cron job.
Periodically sending requests to Facebook
You can group your users into batches and periodically update their values via Facebook and storing in your database.
Combination
Naturally, you can combine the approaches, for instance, you can store in local memory, file, or localStorage values and in the database in the same time, so first locally stored information is searched for, not needing even a request if it exists and is still valid. If not, then checking the database record and using that if it exists and is still valid. And if the data is not found in local resources, nor your database, then you can send an API request.

Testing Pagination of Facebook Graph API

I need to test that I can fetch subsequent pages of reviews from facebooks graph API.
The issue I have is that an account can only review a page once, and pagination doesn't kick in til there are over 100 reviews.
Do I really need to create 101 user accounts and have each one of them manually submit a review, just so I can be sure that when real companies use the software I'll be able to fetch the paginated results correctly?
Is there an alternative?
The issue I have is that an account can only review a page once, and pagination doesn't kick in til there are over 100 reviews.
That’s just the default limit for that endpoint - but you can specify a different limit in your initial query (simply via the parameter of the same name, /page/ratings?limit=3)
The prev/next links generated by the API then also use that limit value.
That way, you should be able to test pagination on smaller datasets as well.

Retrieve number of members of a Facebook group on a certain date

Does anyone know if there is a way to retrieve the number of members a FB Group had on a certain date?
The usecase is that I want to make a historical graph of member-growth.
A hack could be to check when current members joined, but then you'd miss all members that have joined and left.
Reading some other discussions, it seems like there is no Insight data available for groups, only registered domains, pages and page posts. You won't be able to access historic data directly. You can start measuring now and build up your graph of membership growth by accessing the group/members API regularly (You can use cron to do this in a lightweight way and add the data to your database).
Not so sure with Facebook groups, but with the Facebook App, you can record the access token of the users for later use. Or you can store member id and date they joined in your database. Heroku provide Postgres for that. For the free cronjob, you can use like setCronjob.com to regularly schedule the offline jobs like gathering and calculating the statistic based on the user data that you stored.

Realtime User friends updates: new friends

Unfortunately the facebook realtime api only informs about something has changed in the friends connection of the app's users.
What do I have to do to identify that UserA has just became friend with UserX?
Currently, anytime I receive a UserA's friends have changed notification from the facebook realtime api, I receive the whole /UserA/friends.json, paging throu the whole result to just identify what has been added since the last time.
While this works, it just feels like a lot of waste in compute-cycles and I like to know if there is a more elegant approach to this...
That's the way it is designed and there is no "solution" for it.
Note that this does not include the actual data values (either from
before or after the update). To obtain those, your app can request
them as normal, subject to the usual privacy restrictions. For data
that you have access to at any time, you may wish to query for that
data immediately following this callback so that it is ready for when
the user returns to your app.
Source: https://developers.facebook.com/docs/reference/api/realtime/
It makes a lot of sense, because Facebook is able to send you ALL UPDATES while not knowing if you have the appropriate permissions to get the new data, so a very easy way to do it in terms of privacy.
If you have a valid user token (in your db) you can retrieve the updated fields via Graph API / FQL and compare it with the data in your database. Without realtime API you need to pull data every x hours/days, which is even more waste of resources.
If you don't have a valid user token you can retrieve the updated fields via Graph API / FQL when the user comes back to your app and compare it with the data in your database. Without realtime API you always need to update/check the data when the user comes back.

Is it possible to implement friends.getMutualFriends using FQL?

I am looking for a way to implement friends.getMutualFriends of Facebook's Old REST API with FQL. The reasons are twofold:
1. getMutualFriends only returns a list of IDs, and I'd like to use a multi-query to fetch additional information for each returned ID (rather than make additional calls to Facebook)
2. I'd like to batch a few such calls together. batch.run is a bit limited (20 calls) and presumably slower than a multiquery.
Unfortunately, I probably can't use the friends table, because while the sourceID is of a user of my app, the targetID may not be a user of my app (Facebook won't even let me select the friends of the target even in a nested query, which is understandable due to privacy concerns.)
But since I can get the mutual friends using friends.getMutualFriends, I'm wondering if there's any FQL equivalent.