How to avoid blocking by amount of access in Facebook Graph?

1

I have a routine for browsing 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 fine 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 block of queries, limited to 600 requests every 6 minutes. I may not be doing the math correctly, but this routine generates 1 request to fetch 10 friends and 10 other stream requests, right?

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

    
asked by anonymous 12.02.2014 / 14:55

2 answers

2

Are you making this requisition for thousands of different posts?

There are three ways:

  • Optimize your queries to make the most of each request, for example using the IN () statement.

  • put a timer that controls the number of requests so that you do not exceed the limit.

  • Facebook identifies the one making the request using the token and IP pair. This means that two applications (which use the same ip) can do twice as many requests. You could for example create some applications to solve the boundary problem, but this is only scalable up to a point.

  • 12.02.2014 / 15:02
    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 designing your application.

    Putting the block of your code that makes queries within a setInterval function with one-second intervals would already be enough to avoid exceeding the maximum number of transactions, but if it really is needed Facebook provides a page where you can trade a greater number of hits per day.

        
    12.02.2014 / 15:01