Facebook API - Get inbox messages count - facebook-graph-api

My Facebook app should show me the friend with whom i have the largest amount of inbox messages. I got all inbox threads and I can get each message in threads, but app uses many API calls so it may get a 'Too Many Calls' error. Is there a way to get only messages count in a thread object?
Please, don't recommend FQL because it's deprecated in current Facebook API version (v2.2)

I don't think it is possible to get a count of the inbox messages, you may try to include a limit parameter to get more comments in one call. But the main point is that you need the read_mailbox permission for this and you will most likely not get it approved:
This permission is granted to apps building a Facebook-branded client on platforms where Facebook is not already available. For example, Android and iOS apps will not be approved for this permission. In addition, Web, Desktop, in-car and TV apps will not be granted this permission.
Source: https://developers.facebook.com/docs/facebook-login/permissions/v2.2#reference-read_mailbox

Related

What's the API full process for subscribing a Facebook page to an app?

I need to allow users to easily subscribe their Facebook page to my app (which uses webhooks).
I've found incomplete posts, largely talking about first gaining an access token for each page, but surely there must be a way to process this via the API, so it's easy for users? The process would be:
User clicks 'add my page' on my web platform
Redirects to Facebook, and asks user to select the page they wish to connect, and grant permission
Returns to my platform and adds the relevant info into the backend, ready for the incoming calls
Is there anywhere this flow is documented? I'm using the NodeJS SDK

How to get permanent Facebook access token now that app's are not being reviewed

Apps are no longer being reviewed, but I need a permanent access token for a current project.
Does anyone know how to extend the access token. The current "extend access token" button that extends the token by 60 days results in this error. As does any request with an "unverified" app id.
facebook.GraphAPIError: (#200) Access to this data is temporarily disabled for non-active apps or apps that have not recently accessed this data due to changes we are making to the Facebook Platform. https://developers.facebook.com/status/issues/205942813488872/
According to Facebook:
"Beginning April 4, 2018, all apps, including those formerly approved,
must undergo App Review in order to gain access to the Events API,
Groups API, and Pages API. Apps accessing the Events API and Groups
API will lose access and require review once App Review resumes. For
apps using Pages API, review will be required once App Review resumes
or access will be removed."
You can read more about it here:
https://developers.facebook.com/docs/apps/review
https://developers.facebook.com/docs/graph-api/changelog/breaking-changes/?translation&hc_location=ufi#groups-4-4
Regarding the error that you receive, I currently have two applications. One which I've been using regularly and one that I haven't used for the past 6 months.
If I send a request to extend my token for the latter one, I receive the same error (which makes sense according to the error message), but if I send a request with the first one, I am able to extend the access token and get the expected response.
Please update us, once the problem is getting solved, let me know how much time Facebook team is taking to review.

Facebook Graph API does not return Page Events

This looks a kind of duplicate question but actually NOT.
So the problem is https://www.facebook.com/julytalk/ has events, for sure.
But when I tried on Facebook Group API toolkit, it returns empty array.
https://developers.facebook.com/tools/explorer/145634995501895?method=GET&path=204859706228731%2Fevents&version=v2.12
Why is this happening?
I could not find any Facebook API endpoint modification notice, at all.
It was working okay before.
Please help me.
https://developers.facebook.com/blog/post/2018/04/04/facebook-api-platform-product-changes
Access to the Events API is not possible at the moment:
...apps currently accessing Events and Groups APIs will lose access today
Update: After Facebook did a lot of changes, it seems to be possible to get events again. You can get events from Pages you manage easily in dev mode. If you want to get public events, you may want to read the answer in this thread: Facebook pages API: "Page Public Content Access" review screencast
The above answer was misleading for me, not because its wrong but because so many things have changed on Facebook's side and I needed further clarification.
This is the current state based on my research (25.08.2020.).
There are several types of events available based on where the event destination is:
User events
Documentation terminology: "Events on User"
API endpoint:
me/events
Page Events
Documentation terminology: "Events on Groups"
API endpoints:
me/groups
group_id/events
Group Events
Documentation terminology: "Events on Pages"
API endpoint:
me/accounts
page_id/events
App Events
Documentation terminology: "Events on an App"
API endpoint:
{application-id}/events
About app events.
The list is taken mostly from Facebooks API event endpoint.
The documentation is wrong on event limitations:
Access to Events on Users and Pages is only available to Facebook
Marketing Partners.
The current state is that "Access to Events on Users and Pages is available to":
A) App Admins (verified with testing)
B) App Developers (verified with testing)
C) App Testers (not verified)
D) Facebook Marketing Partners (not verified)
What does this mean?
This means if your query the "me/accounts" endpoint which will give you a list of page ids.
When you select a page id and then query "your_selected_page_id/events" you will receive:
An empty list if you are not A-D)
A list of events which is not the same as your users.
A lot of confusion and frustration because there is no error message thrown.
I have tested this with different API versions 4.0 - 8.0 and the results were the same.
I have also tested this with a different but similar set of permissions, resulting in the same empty array response.
SOLUTION(S):
TODO: UPDATE: Clarify who needs to become FMP.
To query for page events "someone" needs to be a Facebook Marketing Partner.
https://developers.facebook.com/support/bugs/352704275741601/
Invite your users to become testers.
Helpful links:
Read more on Facebook Marketing Partners.
Officially on Facebook Marketing Partners.
Facebook Graph Explorer.
Facebook Batch Requests.
Additional notes:
Page event fetching has the same requirements as user events fetching.
Group event fetching works for all users (ignores A-D).
Creating batch requests with no FMP will result in response sections that only have empty arrays.

Deprecated Facebook login permissions

My app integrates Facebook login with the following permissions :user_education_history and user_work_history. The app was working just fine until today morning when I attempt to login I get the following error:
invalid scopes: user_education_history, user_work_history. This message is only shown to developers other app users will ignore these permissions if present.
I went through the docs and I discovered that they were deprecated on the 4th of this month but I cannot seem to find the new permissions for the education and the work history ... any help ?
Facebook is removing access to a lot of things as a result of recent negative press surrounding data mining of their users. In almost all cases the information is simply no longer available, there is no alternative method to access it.
More information is available in the Facebook developer blog:
https://developers.facebook.com/blog/post/2018/04/04/facebook-api-platform-product-changes/
https://developers.facebook.com/blog/post/2018/04/24/new-facebook-platform-product-changes-policy-updates
Note that the message you mention is only shown to Facebook accounts with developer credentials. Regular Facebook users don't see this message and the Facebook API simply ignores requests for scopes which are no longer allowed. If the data being requested are optional in the context of the app, you should create a test Facebook account and see how it behaves when requesting the data doesn't return anything (or causes unexpected errors).

Auto post on friends wall when user logged in using Graph API for first time

When first time a user logged in through Facebook Graph API APP, whether any auto post will be triggered to others wall on user's behalf regarding new APP first Login?
APP is given permission to read_stream, publish_actions.
That is not allowed and not possible for many obvious reasons:
You are not allowed to autopost, not even on the wall of the authorized user. Every single post has to be approved by the user.
You are not allowed to prefill the message, it must be 100% user generated.
You can´t post to the wall of friends (anymore), that would be spam anyway.
...also, you will not get read_stream approved, but you would not need that permission for posting anyway:
This permission is granted to apps building a Facebook-branded client on platforms where Facebook is not already available. For example, Android and iOS apps will not be approved for this permission. In addition, Web, Desktop, in-car and TV apps will not be granted this permission.
Source: https://developers.facebook.com/docs/facebook-login/permissions/v2.2#reference-read_stream
Don´t create spammy Apps. User friends don´t care if the user just started using your App. You may want to read this too: https://developers.facebook.com/docs/apps/faq#invite_to_app