Facebook Oauth 2.0 and rate limiting - facebook

I am trying to extract Facebook ids from a list of emails using the url:
let url = "https://graph.facebook.com/search?q="
+ email.Replace("#","%40")
+ "&type=user&access_token="
+ facebook.Token
After around 600 id extracts I get the error "The remote server returned an error: (400) Bad Request.". Is the facebook API/Search rate limited? If so where is the doc?

Facebook limits you to 600 calls/600 sec - but it does reset after 10 minutes. I can't find the documentation at the moment, but I was told this at a Facebook developer garage

Related

Facebook Graph API - Page request limited reached but have page_engaged_users

I'm developing an application that manages 100+ Facebook pages. On some page I'm getting the following error:
{
message: '(#32) Page request limited reached',
type: 'OAuthException',
code: 32,
fbtrace_id: 'CzEElQoxHuu'
}
The pages that display this message have page_engaged_users over the previous 24 hours.
I understand that from here if I have a single page_engaged_users I should be able to make 4800 requests. However each Facebook Page is making a max of 390 API requests per 24 hours.
Does anyone know that if I have at least one page_engaged_users in the previous 24 hours I can make up to 4800 requests?
I can't seem to find any contact information for Facebook to support ticket forum etc.

facebook - how to get a new authorization code for an access token

I've read through the documentation and I don't understand how to get the new code, I was doing this to get a token to read the feed for a site I'm an admin on:
https://graph.facebook.com/oauth/access_token?client_id=" + sClientID + "&client_secret=" + sSecret + "&redirect_uri=" + sRedirectURI + "&code=" + sCode;
and then:
"https://graph.facebook.com/" + sUser + "/accounts?" + sToken;
To get the feed.
It's telling me:
{
"error": {
"message": "This authorization code has been used.",
"type": "OAuthException",
"code": 100
}
}
I know I need a new authorization code but cannot find the method to call to get one in the documentation. Alternatively, is there another way to get this feed?
STEP 1:
Please open your browser, type the following URL and hit.
https://www.facebook.com/v8.0/dialog/oauth?client_id={app_id}&redirect_uri={redirect_uri}
STEP 2:
Let's assume your {redirect_uri} = https://www.abc.co.in/.
Then you will receive new authorization code with the following format in the URL itself.
https://www.abc.co.in/?code={get_new_auth_code_here}
STEP 3:
Get the access token by the following URL with said new authorization code.
https://graph.facebook.com/oauth/access_token?client_id={app_id}&client_secret={app_secret}&grant_type=authorization_code&redirect_uri={redirect_uri}&code={newly_received_auth_code}
Cheer!
You may need to re-read the login documentation: https://developers.facebook.com/docs/facebook-login/login-flow-for-web-no-jssdk/
You use the code one time only, and exchange it for an access_token - you then use the access token to make API calls on behalf of your users.
When the token expires (in approx 60 days) or the next time the user comes back to your app, you send the user through the login flow again, get a new code, and exchange that for a new token which will be valid for up to 60 days

Facebook notification FQL query problems

I want to retrieve the current user's notifications from the past 8 hours. I'm using the Graph API Explorer on FQL mode before I put this into my app. On permissions, I have user_about_me and manage_notifications. The request i'm searching for is this:
SELECT notification_id FROM notification WHERE recipient_id={0}
But it returns:
{
"error": "Request failed"
}
What am I doing wrong?
The error Request failed
generally occurs when the your request in not correct.
If you read the documentation properly, this API is used to fetch -
The current user's notifications
So, only valid recipient_id could be the current user's id or me(); not his friends or any other user.
If you have tried the current user's id to the recipient_id, that means the id you've provided with {0} is not correct (some syntactical error).
So, instead you could simply write recipient_id = me()

Application request limit reached for facebook

I got this error for some reason:
{
"error": {
"message": "(#4) Application request limit reached",
"type": "OAuthException",
"code": 4
}
}
From my investigation, daily request limit seem to be 100m requests. The Insights -> Developer -> Activity and Errors does not update in realtime (lagging by 4 days), there isn't any restrictions/throttling/errors to speak of. The highest request rate I had was on 21st, and it is 500k and I don't think i got any request limits reached errors (error highest was 1000 errors that day).
Any idea what I could be doing to resolve this? Or at least find out what limits are to my app?
I have same error.
I think there is a facebook bug: https://developers.facebook.com/bugs/442544732471951?browse=search_50bc5133cf13d5c74557627
Please subscribe to this error to solve it quickly...
Quote from here: Facebook Application Request limit reached
There is a limit, but it's pretty high, it should be difficult to hit unless they're using the same access tokens for all calls and not caching results, etc. It's 600 calls per 600 seconds per access token.

Facebook graph API 'friends' request now only returning 25 friends per page? What's going on?

My application(game) has been running on Facebook for some time. I start by requesting a friends list via the graph API call: my-uid/friends
asking for user name and profile pic.
Normally I get back a list of all my friends up to a few thousand, until it starts putting friends on to the next page. Which is nice as most of my users get friends in 1 call.
Suddenly however, and with no changes to the app. about 40 minutes ago (18:40 Tuesday (PDT) - 2nd May 2012) I started getting responses with only 25 friends per 'page'!
I can still get my whole friends list using multiple calls, but the game is not currently set up to do that properly. Can anyone tell me why the sudden change? Anyone else seen similar problems and how do I get the list to give me up to 5000 friends per page like it used to.
Reproducible using the Graph API Explorer
I don't know what else to tell you; perhaps the default number returned has changed, but when I try, a call to /me/friends?limit=5000 returns the full list for me (but my friends list is >500 and < 1000 , so maybe it cuts off somewhere along the way)
(Side note: the average number of friends has been found to be ~190 so presumably most users will have less than 500 anyway, and having to page above 500 would be an edge case
In SDK 4.7 you need to pass in a bundle with the number of friends you want to return, I have set it to 5000 as this is the maximum number of friends you can have on Facebook.
You also need to set up your app as a game in the facebook dev console and use invitable friends to get a full friends list
Create your bundle
Bundle bundle = new Bundle();
Add params to your bundle
bundle.putInt("limit", 5000);
Then pass it in to your GraphRequest
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me/invitable_friends",
bundle,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
//Do something with the response
}
}
).executeAsync();
It seems that facebook changed its limit to 25 results in other api calls too (feed, posts, friends, etc), if you request friends without parameters the JSON response shows the following:
"paging": {
"next": "https://graph.facebook.com/USER_ID/friends?format=json&limit=25&offset=25&__after_id=LAST_ID"
}
Anyway you could/should always set limit & offset parameters to prevent this kind of things, limit = 0 will return all your friends list.
https://graph.facebook.com/USER_ID/friends?limit=0
If you are only requesting friends from a normal user the maximum number allowed is 5,000 so the limit should could be either 0 or 5,000 if you are requesting info from a facebook page or other kind of api calls like posts or feed this limit could increase or decrease.
(Update) Facebook fixed this bug so setting limit to 0 returns 0 friends, you should set a positive limit, thanks Dinuz
I think the best thing you can do is to add limit=5000 parameter as Igy says.
However I posted a bug report since this change wasn't noticed or described in the document.
The number of results returned from the /v2.2/me/friends endpoint now defaults to 25.
Friend list now only returns friends who also use your app: The list of friends returned via the /me/friends endpoint is now limited to the list of friends that have authorized your app.
See Facebook changes
Facebook API change log
If you are using GraphRequest() (e.g. in React Native), you can put it directly in the string field, like so :
new GraphRequest(
'/me',
{
accessToken,
parameters: {
fields: {
string: 'id,email,first_name,last_name,friends.limit(5000)'
}
}
...