2

After battling for many days to write a PHP script to access the feed data from selected public Facebook pages, I finally got the below code to work.

I deployed the script on my server and applied a cron to run it every hour or so for almost a month with no problems but yesterday suddenly it stopped working and now spits out the error:

Unsupported get request. Object with ID '483096775077541' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api

What has changed, could someone please help?

<?php
$config['App_ID']       = 'xxxxxxxxx';
$config['App_Secret']   = 'ssssssssssssssssssss';
$token_url = "https://graph.facebook.com/oauth/access_token?"
    ."client_id=".$config['App_ID']
    ."&client_secret=".$config['App_Secret']
    ."&grant_type=client_credentials";
$grant      = json_decode( file_get_contents($token_url) );

$page_i         = 0;
$page_target    = 1;

$graph_url  = "https://graph.facebook.com/483096775077541/feed?access_token=".$grant->access_token;

while ($page_i < $page_target) :

$feedtext   = file_get_contents($graph_url);
$feed       = json_decode( str_replace('\n','<br />',$feedtext) );

foreach($feed->data as $data)
{
    if( isset($data->message) ){
        $lines = explode('<br />', $data->message);

        echo '
        <p>
            <strong>'.$lines[0].'</strong>
            <div>'.$data->message.'</div>';

        echo '<div>'.$data->updated_time.'</div>
            <div>'.$data->id.'</div>
        </p>
        ';
    }
}

$graph_url  = $feed->paging->next;

$page_i++;

endwhile;
  • Becareful with Facebook data scandal, they change their API (we have same problem with Instagram for example, they limited the request by hour to 200, before it was 5000). Check the documentation if they change somehting, I think they limited a lot of things – Mickaël Leger Apr 05 '18 at 09:20

1 Answers1

2

https://developers.facebook.com/blog/post/2018/04/04/facebook-api-platform-product-changes

As we begin enhancing our new app review process and make changes to our platform, the Events, Groups, Pages and Instagram APIs will no longer be available to new developers

Since this stopped working yesterday, it is definitely related to the recent changes. The only thing you can do is wait right now.

andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • thanks for pointing that out but I dont understand their definition of a "new developers" because the App ID Im using is for an FB App I created last year. – user2363863 Apr 05 '18 at 09:35
  • i believe they closed access for pretty much everything at the moment. and it can take "a few weeks" before they start with the review again. i would not count on getting access to public pages you do not manage anyway though... – andyrandy Apr 05 '18 at 09:46