Piyush Srivastava
Piyush Srivastava

Reputation: 94

unable to fetch data from close group using Facebook graph api

I am unable to fetch closed group posts from facebook. As I'm the member of that group but i cant access it via my access token in graph api. But I can fetch all the data from open groups with my access token in which i am a member.

I am using this url: [https://graph.facebook.com/my-group-id/feed?access_token=my-access-token]

My Code:

<?php
   $group = array(
    array('id'=>'xxxx','name'=>'zzzzz'),
    array('id'=>'xxx' , 'name'=>'yyyy'),
    );

  $access_token = 'my token';

  $n = count($group);
  $i = -1;

  while($n--){
        $i++;
        $add = 'https://graph.facebook.com/'.$group[$i]['id'].'/feed?fields=id,name,story,message,updated_time&access_token='.$access_token;
        $json = file_get_contents($add);
        $data = json_decode($json);
        if($json){
            foreach($data->data as $item){
              $post_id = $item->id;
              $name = $item->name;
              $date = $item->updated_time;
              $story = $item->story;
              $message = $item->message;
            }
        }
  }
?>

Upvotes: 0

Views: 476

Answers (1)

skbly7
skbly7

Reputation: 1162

Facebook has discontinued allowing group feeds (non-Public) on Graph API since app version 2.4.

If you wish to use this feature, you need an application of version 2.1 - 2.3 for the time being. Usage and API documentation can be found here.

Upvotes: 2

Related Questions