Search code examples
phpwordpresshttp-status-code-403

Any way to avoid getting denied (403) due to sending multiple PHP file_get_contents requests?


I have written a WP plug-in that does the following:

On every page load, the plugin retrieves Facebook graph data ( social count ) for the entire blog posts, using file_get_contents() and XML feeds. I tested it on a live site that has more than 60 posts, and when I was still doing some tests, I suddenly got my IP blocked and gets denied every time ( 403 ).

My question is, is this going to happen to real users if they install this plug-in and their visitors ? is there such way to avoid getting denied due to many PHP requests? I also use WP Transients API to cache data for an hour.

Regards.

P.S: I tested the plug-in on my localhost and it works fine.


Solution

  • I found this cool tool:

    http://api.facebook.com/restserver.php?method=links.getStats&format=json&urls={URLs here separated by commas}
    

    which lets me fetch data so fast for 63 URLs that I tested. I don't know if there's a limit, but will definitely read about it.

    Thanks everyone :)