This used to work for me before, but some time ago I realised it doesn't work any more. I'm trying to run a FQL query for retrieving user_online_presence status (whether user is available for chat) on facebook. So, my query goes like this:
SELECT online_presence FROM user WHERE uid=userID
where userID is the actual user id on facebook.
But, regardless I'm online or offline on facebook, this query always gives me 'offline' status instead of 'active' (or 'idle').
To reproduce this on your own, simply go to the Graph API Explorer, obtain a token with permission user_online_presence, and type in the box:
fql?q=SELECT uid,online_presence FROM user WHERE uid = me()
I would really appreciate if anybody can help me with this. Thanks!
Related
SELECT uid, name, sex FROM user WHERE uid IN (SELECT uid FROM event_member WHERE eid in(256178797901718) and rsvp_status='attending') order by name
The purpose of the query is to get all the users' ID, name and sex who are all attending for a Facebook event.
Is there any other way to try with Graph API instead?
Facebook API Version : 2.0
Event ID : 256178797901718
I have tried other ways by removing rsvp_status condition, I am getting users data except sex.
FQL is deprecated, you should not use it anymore. This would be the correct endpoint for the Graph API: https://developers.facebook.com/docs/graph-api/reference/event/attending/
I don´t think it is possible to get the gender though, i just tried with an example call and the gender is not in the result: /[event-id]/attending?fields=id,name,gender
The problem is not with the request syntax – it is a permissions issue.
Requesting the gender field requires public_profile permission – and users would have to log into your app and grant it that permission, before you can get the value.
You can easily test this with an event you are yourself attending:
Login to your app (that grants public_profile permission by default for web login), then request the list of users attending the event using /[event-id]/attending?fields=id,name,gender as luschn already suggested in their answer – and you will see, that for your own account, the gender field is returned (and for other users attending the event that have logged in to your app before, if there are any) – but for everyone else it simply won’t be returned.
My application is posting on wall on behalf of the user with user access_token. Once it is posted I get back the post_id which is persisted in DB. An an application I would like to query the post using the post_id to collect some basic insights like comments and likes. I can't get my app to query the data.
I tried stream table but doesn't return data as an app. I get "GraphMethodException" code:100
I checked privacy settings on post but that doesn't include permission for an app
I tried GraphAPI /post_id which returns same error as stream table
I tried insights table with post_impressions metric with no luck. I couldn't give the post_id so tried removing the user_id part from post_id(xxxx_yyyy where xxxx is the userid)
What kind of permissions do I need to request user to grant my application stream_read permission?
How do I query insights table with the post_id that I have?
You can only read the user wall with an active user access token, and the read_stream permission.
About the insights: maybe with this graph connection?
/[post-id]/insights
Well, it gives me nothing for a valid post id. But i am sure you can only get the insights of pages, not user accounts.
See here (about pages, but maybe useful additional info): Unable to access a post's insights for someone else's page
One more reason why it will not work, just popped up in my head:
If you go to a facebook page, you have the insights view as admin. Nothing like that on a user profile. So the only thing you can track is how often a link to your app has been clicked after posting it to a user profile. You can easily add tracking information to the link too, so you always know from which profile the click comes.
I'm tring to get my friends' birthdays in my app and some of them are null. I thought that those people don't have a birthday set, but they actually do.
My fql query is:
SELECT uid,name,birthday_date FROM user WHERE uid IN (SELECT uid2 from friend where uid1=me())
The birthdays are also null when I request /me/friends?fields=birthday
My access token has the friends_birthday permission set.
I also tried with birthday instead of birthday_date in the FQL query. Same result.
I imagine that this happens because they opted out somehow, but I don't know how.
Is there an alternate solution to actually get their birthdays from facebook?
It's also possible to remove the ability of apps to access your data when your friends use them, this option will prevent the current session user from seeing some information about their friends via the API, even if that information is accessible on Facebook.com
This setting is in the privacy settings, at https://www.facebook.com/settings/?tab=privacy, under Ads, Apps and Websites -> 'How people bring your info to apps they use' and looks like this:
{edit} you can test this for yourself with test users, it's the most likely reason assuming the birthdays are visible to you in the frontend
These people might have set their Birthdays visible to only themselves or only some restricted friends. This is an option available if we try to edit our Birthday by its side. That can cause it is not available to your query by app.
I'm facing a trouble with some code that used to work before. I want to retrieve information whether user is currently online on Facebook's website chat. Thus, I'm requesting access token with 'user_online_presence' privilege and when running fql query:
"SELECT uid, name, pic_big, online_presence, status, current_location
FROM user
WHERE uid="+userId
(where userId is replaced by the real id of the user)
'online_presence' field is always 'offline' although I have my test account opened in the browser and test user is online for chat. All other information is presented correctly. And I know that this code used to work couple of months ago. I tried with several user account, but the same result always.
Is anyone facing similar issues? Has there been any API change I'm not aware of (I did search for the ones related to the online_presence field in 'user' table but without any success)?
Thanks a lot!
It's a long shot, but have you tried using WHERE id = me() rather than feeding in the user id?
I would like to get friends of friends via an API call and when I try to do it, I get the following exception,
{
"error": {
"type": "OAuthException",
"message": "(#604) Can't lookup all friends of .... Can only lookup for the logged in user (...), or friends of the logged in user with the appropriate permission"
}
}
The URL I am trying to access is,
https://graph.facebook.com/friend_id/friends?access_token=access_token
I am getting extended permissions which is as follows,
<fb:login-button perms="user_likes,friends_likes"></fb:login-button>
Could any one please let me know what's going wrong here? Or does it mean I can never get access to friends of friends?
Currently, there is no extended permission that allows you to view a user's friends of friends. The "*_likes" permissions just show you the Facebook pages that the users have Liked.
It might be possible for you to iteratively fetch and cache the friends of each of the user's friends, one by one, but without access tokens for each friend, you'll only be able to fetch public data.
I got friends of friends(limited). I had same problem. Though it is very late for answering question, it will help somebody. That's why answering this question.
We can get friends of friends those are app users.
$fb_id= user id whose friends of friends required.
$query="SELECT uid, name, work_history FROM user WHERE uid IN (SELECT
uid2 FROM friend WHERE uid1 IN (SELECT uid FROM user WHERE uid IN
(SELECT uid2 FROM friend WHERE uid1 = $fb_id ) and is_app_user=1) )";
$user_info=$facebook->api(array('method'=>'fql.query',
'query'=>$query));
#Olie:
You are fetching your friends of your friend through application. So you would need permission from your friend whose friends you want. i.e. Your friend should be using that application and accepted those permission while allowing accessing information. Otherwise you wont be able to friends of your friend. I have tested this query. And it works successfully.
"message": "(#604) Can't lookup all friends of .... Can only lookup for the logged in user (...), or friends of the logged in user with the appropriate permission"
This message explains well. Read carefully.
Hope you understand solution criteria.
You cannot get friends of friends, it is not allowed due to privacy concerns.
A workaround we have done before is to save all users friends to oure own database.
That way we could cross-reference all the different users friend-list's and at least get friends of friends who have used the application we made.
Important note, such a table would quickly grow quite seizable depending on the amount of users you get.
Count on each user having about 250-300 friends on average, so if you opt for such a solution make sure to optimize your database for it, and then it should work just great.
Got same problem, had to use old REST API to get at least mutual friends, see
http://developers.facebook.com/docs/reference/rest/friends.getMutualFriends/
You can get the friends of the current user through a Graph API call to me/friends. You will need any valid access_token, no special extended permissions, just the Basic one. There is one caveat, that user must allow you to see their friend list. So in the Privacy Settings > Connecting on Facebook there is a "See your friend list" setting. If the user has chosen a custom setting and selected say "Only Me" you will get this error.
Similarly, if the current user allows others to see their friend list, but one of the friends shuts this down due to privacy concerns then you will not be able to see any data and will get that error.
I was able to verify the scenarios I have described.
Unfortunately, I can't ask your answer specifically since I don't have experience with the FB API. However, I believe that FB allows users to hide who their friends are. If they have this set, then perhaps you won't be able to access their friends at all. I'd try to modify your code to first check what the permissions of a given user are and only then accessing their friends list if you have access to it. A bit of speculation here, though.