Get Facebook user work - facebook

I'm trying to write some application that scan user's group posts. When I read the group feed posts using the API I’m interested to get some information on the one who posted this post ('from' field). The graph API today gives only the id and the name of this person. I'm interested also in his work place. I tried taking the user id and to access the / resource and to get his work field , but this field is not returned. When I’m looking on the same user profile in Facebook I see his work place is public, even I’m not connected with him.
Anything I can do to get this user work with the existing Facebook API?

Normally, if the work history info is not public, you'll need the "user_work_history" permission (see https://developers.facebook.com/docs/facebook-login/permissions#reference-extended-profile).
If it's public, you can try calling the
/{USER_ID}?fields=id,work

Related

How to retrieve my own comments from a public group on Facebook

I am attempting to retrieve my own comments from a public group on Facebook, using the Facebook Graph API. This is a public group of which I am not an administrator.
I have attempted a number of strategies, but to no avail so far. I keep hitting brick walls, e.g.:
The xxx'yyy' is only accessible on the User object after the user grants the 'user_managed_groups' permission.
If I go on my own profile activity log, I can see those comments, so I would have expected there should have been a way to retrieve those programmatically through the Graph API.
Am I mistaken?
UPDATE
On the chance that I am indeed mistaken, I have sent the following feedback to Facebook:
I would like to b able to retrieve my own comments from a public group on Facebook, using the Facebook Graph API. This is a
public group of which I am not an administrator.
At the moment, the Graph API documentation (v2.12) states that to read the feed I need to provide a user access token for an Admin of
the Group with the user_managed_groups permissions.
Please note that if I go on my own profile activity log, I can see those comments, so I would have expected there should have been a way
to retrieve those programmatically through the Graph API.
Group feeds are only accessible with an access token of a group admin now.
Please note that if I go on my own profile activity log, I can see those comments, so I would have expected there should have been a way to retrieve those programmatically through the Graph API.
The main difference is, that you are one single person looking at your own data. But if I create an app and have a hundred thousand people log in to it and it was possible to read that data, then I could accumulate it for whatever shady purpose ...
(Now with the feed of a public group that might seem a little over the top, I know - but I think the general idea is to make automated data collection harder.)

Get list of events user is attending on Facebook

I'm trying to get list of events my friend / user attends. This info is publicly visible through Facebook pages.
I'm making a request to /userid/events but it returns empty array of results, though user does have upcoming events and calling /me/events is working. (all is ran in graph explorer)
I couldn't find any documentation about any limitations or required permissions to explain why it's not working e.g. this link
Is it a bug? How to workaround it?
You can use /userid/events with a user who auzhorized your App, but using /me/events is recommended. Either way, just because stuff is public on facebook.com does not mean you can get it with the API. You always need to authorize users before you can get any data, for privacy reasons.
In other words: It´s not a bug, there is no workaround, it´s not possible without user authorization.

Get correct id from facebook

I'm trying to get a username from facebook id - I found a way to do it:
https://graph.facebook.com/id?fields=link
however, i noticed that using the graph api, when writing 'me' in the fileds I get a different id from when I use this site :http://findmyfacebookid.com/
And only when using the id from the http://findmyfacebookid.com/ site, the https://graph.facebook.com/id?fields=link works
Anyone knows how to get the id that works every time using the graph api?
Thank you!
Since v2.0 you only get an "App Scoped ID", there is no way to get the "real" ID anymore, and there is no way to get the "username" either. See the changelog for more information.
You should not need the username anyway. If you want to identify returning users, you can just use the App Scoped ID. And if you need to match user between different Apps, you can use the Business Mapping API.

Retrieval of user's likes using Facebook Graph API sometimes fails

in our game I'm checking if user is liking some of our Facebook sites.
For most users its working but there are some complaining that they are
having problems with this functionality.
1) I'm requesting "user_likes" permission during logging to Facebook
( users must be logged ).
2) I also take into account so called "paging" of result via Graph API.
( I'm retrieving all user's like-ids piecewise and after many tests
I assumed that it's working fine :o) )
3) Those users that were reporting that this check isn't working
really "like" those sites (before running this check).
So my assumption is that request "me/likes" fails or doesn't work
as expected under some conditions. Can someone help me with this
problem?
It seems that I'm not alone because I found these (unluckily unanswered):
https://stackoverflow.com/questions/10772814/checking-facebook-graph-api-for-user-likes-fails-for-some-users
http://facebook.stackoverflow.com/questions/10109773/cant-obtain-user-likes-in-some-cases-using-facebook-graph-api
The only cause I can think of is the Graph cache not being up to date with the user's Like data. If the user only just liked a page, and then you requested the Like data via Graph API, the data may not have been updated yet and therefore would show up as a "non-Liked" page.
Try using a FQL query to do the same check - but instead of paging through the user's like, do a direct check on the Page ID, User ID and Like status. You will have to join across multiple tables to get it working.

How would I get a list of 'friends' who have added my Facebook application?

I'm really struggling with something that should be a simple matter: Showing a user of my Facebook app a list of their friends also using the app. Is there nothing built into the APIs to allow such a common request?
The only thing I can think of to do is to get the list of the user's friends, and then get all the users from my database who are in that list, and then fetch information for each of those facebook ids. But that seems an extremely roundabout way of doing things...
The only way I've found to do this is to use FQL and a previously documented, but now undocumented field:
SELECT uid,name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=<user's uid>) AND is_app_user=1 ORDER BY name
The undocumented field is the user.is_app_user, which is listed in the old documentation wiki but not in the shiny new docs. No idea if this means it'll be removed in the future, but there doesn't seem to be any other way to get this data with the new Graph API.
Just in-case you're still using the old REST API, you can also call the friends.getAppUsers method.
You can actually use Facebook's old REST API to do this by sending a GET request to: https://api.facebook.com/method/friends.getAppUsers
If you need JSON data back, then add the parameter format=json
You need an access token to do this. See the documentation here:
http://developers.facebook.com/docs/reference/rest/friends.getAppUsers/