HTTP 403 during request for URL info in Graph API

admin

Administrator
Staff member
I have a wordpress blog. I need to index how many times each page was shared and sort my posts by number of shares.

I made small script what makes requests for each page in a blog, like

Code:
 while ($posts->have_posts()) {
                    $posts->the_post();
                    $obj_fb = json_decode(file_get_contents('http://graph.facebook.com/?id=' . get_permalink()));
                    $likes_fb = $obj_fb->shares;
                    update_post_meta($post->ID, 'meta_fb_likes', $likes_fb, false);
                }

Notice I not use any access tokens.

The script works for certain number of pages, like 50 or 100, but when I process large amount of pages, like 300 or so, it takes about a minute and returns an execution error 403 from graph api.

Please advice what I'm doing wrong.