How to avoid blocking by number of accesses on Facebook Graph?

Asked

Viewed 1,009 times

1

I have a routine for consulting the last 50 posts:

FB.api('/me/friends?limit=10', function(response) {
    var friend_data = response.data;
    for(var i = 0; i < friend_data.length; i++) {
        FB.api({
            method: 'fql.query',
            query: 'SELECT post_id, source_id, message FROM stream WHERE source_id = ' + friend_data[i].id + ' LIMIT 50'
            },
            function(posts){
                console.log(posts);
            }
        });
    } 
});

It works perfectly until I get this error message:

"error_code":"613"
"error_msg":"Calls to stream have exceeded the rate of 600 calls per 600 seconds."

Of course, there is a lock on the number of queries, limited to 600 requests every 6 minutes. It may be that I’m not doing the accounts correctly, but this routine generates 1 request to fetch the 10 friends and another 10 requests stream, right?

Is there anything that can be done to get around this problem?

  • Have any reason to make more than one request per second on a page?

  • 600 requests every 10 minutes. 600 seconds = 10 minutes.

  • The context in which your query exceeds the request limit is essential to the problem, please clarify.

  • I changed the question to increase understanding.

  • @Alexandrebonfá The problem is still unclear. There are 11 requests, and as Facebook identifies you based on IP + TOKEN, this should work for all its users. If the problem is the user updating the list very often, then you should make the request in the backend and control with database when you should bring the database information and when you should make a new request after X minutes past the last.

2 answers

2

You are making this request for thousands of different posts?

There are three ways:

  1. optimize your queries to make the most of each request, for example using the instruction IN ().

  2. set a timer that controls the amount of requests so that you do not exceed the limit.

  3. Facebook identifies the one who makes the request using the token and IP pair. This means that two applications (using the same ip) can make twice as many requests. You could for example create some apps to solve the limit problem, but this is only scalable to some extent.

1

If your application is making more than 600 requests every 6 minutes (ie 1.66~ requests per second) there is probably something very wrong with the way you are structuring your application.

Placing the block of your code that makes the queries inside a function setInterval with one-second intervals would be enough to avoid exceeding the maximum amount of transactions, but if it is really necessary Facebook provides a page where you can negotiate a larger number of accesses per day.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.