Get the list of user groups with Facebook API - facebook

I'm trying to get a list of the user's Facebook groups.
To do this, I analyze the documentation to understand it (Graph API) :
https://developers.facebook.com/docs/graph-api/reference/v3.2/user/groups
However, when I use this query, I get no results
I've done a lot of research.
And from what I understand, it is no longer possible today to obtain the list of user groups (depeacrated)
However, I do not understand. The documentation page still exists, for version 3.2 ( https://developers.facebook.com/docs/graph-api/reference/v3.2/user/groups) and nothing says that this is no longer possible.
Documentation says :
Returns a list of Groups where the User is a member and the User has granted the app any Group-level permissions for that Group "
My code :
FB.api(
"/" + id + "/groups",
function (response) {
if (response && !response.error) {
console.log(response);
}
}
);
I would like to get a list of all the user's groups, not just the groups where he is an admin.

https://developers.facebook.com/docs/graph-api/reference/user/groups/
admin_only=true
pass this parameter you will get only list of those groups where you are admin.

I managed to get the groups, when askd for groups_access_member_info permission during the facbook-login process, but it asks too much: with this permission app can post in your groups as well and can read former posts. I guess nobody will give you this rights, it seems this feature is over.
Additionally: in my privacy settings i found that the list of my groups are private information (haven't set is explicitly .. at least i dont remember) so it's maybe practically deprecated because of this default setting.

Related

Get friends of a User using Facebook API

I am facing a problem in fetching the friends of a user. The following code is working fine when "me" is passed as an UID. But it doesn't work when a user id is passed like 523621551. Every thing is set in the permissions. And i get the "Unsupported operation" error. Following is the code.
public function getAllFriends($uid) {
return $this->fb->api("/" . $uid . "/friends", 'GET', array(
'access_token' => $this->fb->getAccessToken())
);
}
So, what is causing this problem?
I also studied other related questions but those didn't help. :(
You can´t get the friends of ANY user, you can only get the friends of the user who is authorized at the moment. The docs are a bit misleading, it may only work with the (app scoped) user id of the authorized user, but it will never work with any other user id - that request is "unsupported" ;)
Also, you can only get the users who authorized the same App too, just in case you don´t know yet. See changelog: https://developers.facebook.com/docs/apps/changelog
Edit: I just tested it with an App Scoped ID in the API Explorer and it works, so i assume you are trying to get the friends of another user as i expected - which is not supported, of course.
I also tested it with the "real" ID of the authorized user and got the following error:
The global ID 1603196280 is not allowed. Please use the application
specific ID instead.
Makes sense, you would not get the global ID in the App anyway, only App Scoped IDs. As i said, the error you get is not very clear but correct: Getting the friends of ANY user is "unsupported".

Open Graph Check Users Permissions

I have a situation on my site where a user who has authorized my app can later opt to get their friends list so I want to check their current permissions before executing anything. I have found I can use
FB.api('/me/permissions', function(response) {
console.log(response);
});
I want to check if the user has read_friendlists permission but I have not found any information about the object so I do not know how to write a condition against it. Facebook has an example of returned data on this page http://developers.facebook.com/docs/reference/api/
but like I said I have not found a resource which describes the object.
Thanks for the help
If there's no read_friendlists entry in the response, you don't have that permission - write your condition based on the presence, or lack thereof, of the particular key (permission) you need

Need to know whether Google Group is Admin managed or user managed in google apps domain?

I am using Google Apps Provisioning API to play around with google apps domains group settings. I have got the list of the all the groups in a domains but I need to know whethet a particular group is User-Managed or Admin-Managed.
I cannot see any method to get that information. I would need some help here if anybody knows about this. Thanks :)
With Google Apps Script, you could get the Owner list using getAllOwners(), and check to see if the owners of the group are admins. Something like:
function isAdminManaged(groupName){
var groupOwners = GroupsManager.getGroup(groupName).getAllOwners();
for (var owner in groupOwners){
var userName = groupOwners[owner];
if(UserManager.getUser(userName).getIsAdmin()){
return true;
}
}
return false;
}
The provisioning API has an undocumented flag you can specify when retrieving all groups with this call:
https://developers.google.com/google-apps/provisioning/#retrieving_all_groups_in_a_domain
if you append ?skipUserCreatedGroups=True to the URI, as in:
https://apps-apis.google.com/a/feeds/group/2.0/example.com?skipUserCreatedGroups=True
then only admin-created groups will be returned. If your group isn't returned by this API call, then you know it's user managed.
Not highly efficient for checking just one group but it gets the job done.

Retrieving facebook user wall posts through graph API

I'm currently working on a facebook app which captures wall posts for a specified user, page or group, after a user has authorized the app I quote the access_token that is returned to call the method
https://graph.facebook.com//feed?access_token=
this works fine for pages and groups as we only need a valid token, however for users the results are different depending on the relationship between the user who authorized the app the user whose posts are being captured.
For example if there is no relationship between the two users some posts are not returned even though they are public and displayed when you view the profile of the user, however if they are friends more posts are returned.
Can someone please explain this behaviour? And is it possible to obtain all posts using this method?
Yes, per the permissions listed at https://developers.facebook.com/docs/reference/api/permissions the results of the call are different depending upon the relationship.
However when things are public and you use an access token that doesn't belong to the user, then no results are returned. I cannot remember a time when this wasn't this way. For some odd reason (by design or omission on Facebook's part) using the graph API to get at public posts using a user access token just doesn't want to work.
For example, You can see some public items here
http://www.facebook.com/zuck
http://graph.facebook.com/zuck
However, you cannot seem to get any feed from here without an access token
https://graph.facebook.com/zuck/feed
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException"
}
}
Let's try adding an user access token that does not belong to zuck or a friend of zuck. https://graph.facebook.com/zuck/feed?access_token={UserAccessToken}
And here's what we get:
{
"data": [
]
}
What about an app access token? Let's try
https://graph.facebook.com/zuck/feed?access_token={AppAccessToken}
{
"error": {
"message": "Invalid OAuth access token signature.",
"type": "OAuthException"
}
}
So as you can see, it's difficult to get things via the graph that are not in alignment with your access token.
I manage to get most of the feeds from user's wall post. Although this is a old post, I hope someone can manage to get what they want from my answer.
Before getting the access token(to get the feeds), you need to add multiple correct Read Permissions "keys".
For example, you will have to add "read_stream", and "user_status" (which I found that these are the most important permission "key" to generate the correct access token, to retrieve one's so-called "public" feeds).
You can add more into generating the access token, in either you want the permission to GET, or POST, or BOTH.
Source is here: https://developers.facebook.com/docs/howtos/ios-6/#nativeauthdialog
One thing that I found is, the way to get the feeds result from user's "Home/About" page and Facebook Page (which is created for people to like (not add friends)) are different. The key is mentioned above, "read_stream", and "user_status". So it's better that you add both of the permissions in order to generate the access token to get everything in feeds.
Graph API doesn't return posts to the App if is not authorized to read user feed, even if posts are public.
Source: https://developers.facebook.com/bugs/290004301178437/
According to the latest api ,
FB.api("/me/feed","get",function(response) {//callback})
should do and also work well .
It is working now but facebook may change it in future.

Facebook Graph API - get friends info

I'm trying to figure out how to get users friends information using either Graph API or FQL
Just for testing I would like to get my friends education_histroy.
To do that I created a test app, requested extended permissions using
scope=offline_access,manage_friendlists,friends_work_history,
friends_education_history,friends_about_me
and got access token to play with the API.
It works great when I query for current user using /me. But it returns nothing for my friends.
I was assuming that if I request, let's say friends_work_history, that extra field (work_history) will appear inside friend's object, when I query by friend's id:
https://graph.facebook.com/FRIEND_ID&access_token=TOKEN
But all I see is basic info about that user (friend).
Then I tried to request that field specifically:
https://graph.facebook.com/FRIEND_ID?fields=work&access_token=TOKEN
With no luck again. Returns just friend's id..
I tried to access that information with FQL:
https://api.facebook.com/method/fql.query?query=select+work_history+from+user+where+uid+in+(FRIEND_ID)&access_token=TOKEN
Returns work_history = TRUE instead of array. And that friend definitely has work history specified.
Can someone help me to understand how to get friends info using my app and extended permissions?
Graph API is the smart choice in most cases. To retrieve your friend information you need to collect some extended permissions from the user first. Then you can retrieve a lot more information other than the basic ones.
Following is a list of extended permissions related to friends different kind of information
friends_about_me
friends_activities
friends_birthday
friends_checkins
friends_education_history
friends_events
friends_games_activity
friends_groups
friends_hometown
friends_interests
friends_likes
friends_location
friends_notes
friends_online_presence
friends_photo_video_tags
friends_photos
friends_relationship_details
friends_relationships
friends_religion_politics
friends_status
friends_subscriptions
friends_videos
friends_website
friends_work_history
Hope it helps :)
I've been wrestling with this all day myself and I believe I have figured it out, nowhere in facebook documentation (that I have found) is this clear. And I don't believe the other answers actually answered your question, it looks like you requested permissions correctly. Anyway, to request the information you are looking for, ping the api like this:
https://graph.facebook.com/userid/friends?fields=work&access_token=ACCESSTOKENHERE
This will return you all the friends' info in one long JSON response.
It is a little confusing because the permissions you are asking for are not the same thing you need to query the API.
The query above will return the friends' ids with work history. You can add commas to the fields parameter to include additional info like name, but then the API calls/responses end up taking a long time.
http://developers.facebook.com/docs/reference/api/user/
you can get all the fields mentioned here .To get work you need to have user_work_history or friends_work_history permission
in the link it is mentioned what permissions to obtain before you get the info and another thing that user has to allow your application,this will make your app to get the informations.
From this answer to another question: a call to 'me/friends?fields=work' worked for me!
I'd suggest that you go to http://developers.facebook.com/docs/reference/api/user/ like most of the others are suggesting but as a general tip, use the friends_education_history as a way to get the friend's history.
P.S: Minor spelling error in your original question that should be edited. "education_histroy." = education_history
in the second line of your main paragraph.
You can use this code you will get name, profile picture, ID of your friends.
FB.api('/me/taggable_friends', function(response) {
for (var i = 0; i < friend_data.length; i++) {
results += ''+friend_data[i].name;
}
});
Before that in your developer account created app-> go to tools and support->graph API explorer-> click Get Token. In that window click user_tagged_places and click Get Access Token. You will get your friends list.