Mico Abrina
Mico Abrina

Reputation: 507

How do I get the posts of a closed Facebook group using Facebook PHP SDK?

Here's my code:

<?php
require_once("../src/facebook.php");

$config = array();
$config['appId'] = 'APP_ID_HERE';
$config['secret'] = 'APP_SECRET_HERE';

$facebook = new Facebook($config);

$facebook->setExtendedAccessToken();
$facebook->getAccessToken();
$patas_feed = $facebook->api('136304296439193/feed','GET');
var_dump($patas_feed);
?>

I'm using this code to get the wall feed of a closed Facebook group. Unfortunately, it returns nothing; however, if I were to use this with an open Facebook group, it works great and creates an array of everything. I think the problem is the access token. How do I make the access token accessible to closed groups?

P.S. I'm a member of the closed group, and I can always obtain admin access if ever.

Update: I gave my account permission to the app. It still didn't work.

Upvotes: 1

Views: 10092

Answers (1)

St&#233;phane Bruckert
St&#233;phane Bruckert

Reputation: 22893

You need to request the user_groups permission to access a closed group information.

To read a Group, you need:

  • any valid access_token if the group is public (i.e. the group's privacy setting is OPEN)
  • user_groups permission for a user's non-public groups
  • friends_groups permission for a user's friend's non-public groups
  • Groups for Apps and Games require the use of an App access_token

Source: https://developers.facebook.com/docs/reference/api/group/

Upvotes: 2

Related Questions