How to get the list of groups and pages of an user

2019-09-08 06:49发布

问题:

I'm using graph api but I can't list the pages and groups of an user.

First, for the permissiones, in the scope, I use: 'scope' => 'publish_stream,user_groups,user_about_me,user_interests,friends_groups,friends_interests,friends_about_me',

and then, when I try the next code, the value of $ct is 0

<?php
session_start();
require 'config.php';
require 'facebook.php';
$facebook = new Facebook(array(
'appId'  => $fb_app_id,
'secret' => $fb_secret,
'cookie' => true,
));
$user = $facebook->getUser();
$info = $facebook->api( '/me/groups', 'GET', array( 'access_token=' => $access_token ) );
$ct = count( $info['data'] );
echo $ct;
?>

回答1:

This may be a silly question, but are you sure:

  • The user is actually in some groups (many users are not)

  • You definitely have the user_groups permission (check with a call to /me/permissions)