You can use the SDK to show all groups a member:
https://developers.facebook.com/docs/graph-api/reference/user/groups/
You’ll need the permission user_groups
and/or user_managed_groups
to list the groups the member manages.
the Endpoint is "/{user-id}/groups"
or "/me/groups"
if to show the groups of the member that is authenticated.
as an example, copy the tapeworm below and place it in the Facebook test page, click on "Run code" (blue button) and then click on the link that will show below the box where you put the code that will say "Show my groups"
<a href="#" id="run-btn">Mostra os meus grupos</a>
<ul id="groups"></ul>
<script type="text/javascript">
document.getElementById('run-btn').onclick = function() {
FB.login(function(response) {
if (response && !response.error) {
console.log("Login ------------------------------");
console.log(response);
getAllGroups(response.authResponse.userID);
} else {
// o utilizador nao deu permissoes...
}
}, {scope: 'user_groups'});
return false;
}
function getAllGroups() {
FB.api("/me/groups", function (response) {
console.log("Groups ------------------------------");
console.log(response);
if (response && !response.error) {
for(i=0; i<response.data.length; i++) {
var group = response.data[i];
document.getElementById("groups").innerHTML +=
"<li><a href='https://www.facebook.com/groups/" + group.id + "'>" + group.name + "</a> (" + group.id + ")</li>";
}
}
});
}
</script>
return of the above code:
balexandre no consele funciona perfeitamente pas using my appid just shows the group I manage vc know pq?
– Rafael Duchatsch
needs the
scope: user_groups
when making the application...– balexandre
even with permission only shows what I manage :/ but just listing by the console has helped me much worth
– Rafael Duchatsch
@user2677216 if you can see what you are admin, it is because you are using
user_managed_groups
, but you also need to use, as I said before and in the answeruser_groups
... you have to re-authenticate with the new permission to return elements... not knowing how you’re authenticating yourself, I can’t help much more... By the way, if it helped you, mark it as the right answer so others with the same question can see what they need to do. :)– balexandre