I'm creating a custom module to deliver an amalgamated news feed from various sources, all ordered by date. One of these sources is FB, and I'm having real issues with it.

I'm using fbapp module as a dependency (https://www.drupal.org/project/fbapp), so that I can use it's authentication fbapp_app_authenticate() and fbapp_graph_request() without having to worry about the constant facebook graph updates making my own code obsolete.

I've created a facebook app, so authentication should be app token, using appid and app secret. This seems fine and I'm getting back access_token. However, when I try to read posts from a publicly available page (the clients), I get the response:

"Unsupported get request. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api"

Here's my code:

$token = fbapp_app_authenticate(variable_get('my_module_fb_app_id', ''), variable_get('my_module_fb_app_secret', ''));
$type = variable_get('my_module_fb_query', -1); // this is "posts" in this case
$graphId = variable_get('my_module_fb_graph_id', '');
$target = "$graphId/$type";
$params = array('access_token' => $token['access_token']);
$data = fbapp_graph_request($target, $params);

As an update, here's the queries and responses it produces:


array(1) {
  string(43) "<redacted>|<redacted>"


string(183) "{"error":{"message":"Unsupported get request. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100}}"

Does anyone know if this is a correct way to query Facebook, or if there's a better way of programmatically obtaining a page posts?


Here's the solution I got on the main stackoverflow site (https://stackoverflow.com/questions/31306242/facebook-graph-api-unsupported-get-request):

If page restrictions apply, the page's feed can only be retrieved with an user access token as far as I know (because FB needs to evaluate the visibility criteria, and setting your app to the same restrictions doesn't help here):



The alternative is to use page access tokens, but you need admin access to the site page to generate those. This means you will receive all posts, regardless of restrictions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.