How to get facebook pending friend requests through fql - facebook

I'm working on getting pending requests by fql. I've set up "read_requests" permission and used following fql:
SELECT uid_from,
message
FROM. friend_request
WHERE. uid_to = me()
But it doesn't work and I do not get anything.
Can anyone help me?

You need the read_requests permission for any friend requests that are sent by or to the current session user.
You can read a list of friend requests sent to the current user -
SELECT time,
message
FROM friend_request
WHERE uid_to = me()
Or, you can check the status of any friend request sent by the current user, but you have to provide the id of the user to whom the request was sent. You cannot retrieve all friend requests sent by the current user -
SELECT time,
message
FROM friend_request
WHERE uid_from = me()
AND uid_to = ID

Related

Querying all users who were invited to a large event (>50K users) returns capped results (<5K users)

I am trying to query all of the Facebook UIDs of users that were invited to one Facebook event. (I'm using this data to analyse trends, with the users's UID being a key part of the formula.) More than 50000 users were invited to the event, which I would like to query. When making a Graph API query (256633941116408/invited) or FQL query (SELECT FROM event_member WHERE eid = 256633941116408) for all of the invited users of this particular event (The event's ID was 256633941116408), my results seem to be limited to 4932 users every time without fail. 59,161 users were invited to this event and should appear in API responses. Even manually limiting the Graph API request to 1000 per page, the response still quits at the same number of invites, only 5 pages later. Is it possible that Facebook does not expose an event's invited users for a public event past the 4932 entry mark, or am I approaching this the wrong way?
Thanks! -Robert
I have the same problem and have found no solution but to repeat the task for "Accepted" "Declined" "Unsure" and "not_replied" to get as much user status as possible. I'm interested at events with more than 100000 invites. I tryed limiting the request by uids too only to face the same deception. You might want to scrap the page and conduct programming on the output, but ou would need to ask Facebook permission. Here is the Facebook web page related to that: https://www.facebook.com/apps/site_scraping_tos_terms.php . Let us know if you find another way.
Good luck!
Try the Limit and pagination, like this:
SELECT uid FROM event_member where eid = 306212359507086 LIMIT 0,1000
SELECT uid FROM event_member where eid = 306212359507086 LIMIT 2000,1000
SELECT uid FROM event_member where eid = 306212359507086 LIMIT 3000,1000
.... until you get an empty response
also check if you have the necesary permissions, if is not your event you may only see about your friends.
try this also:
SELECT uid FROM event_member where eid = 306212359507086
AND uid IN (SELECT uid1 FROM friend WHERE uid2=me()) LIMIT 0,1000
dont forget to change the event id

Facebook post impressions are null in FQL stream query

According to the FQL Stream documentation the following query is supposed to return impression counts when run by an authenticated page owner, yet it never does. We have the page owner authenticating directly in the graph api explorer with extended permissions (read_stream, read_insights), but the impression counts are always null.
Is anyone able to get this working?
SELECT post_id, actor_id, message, impressions FROM stream WHERE actor_id = {owned_page} and source_id = {owned_page}
I think its missing in the documentation, but you should make this call using the page access token instead of user access token to get it worked.
So here are the steps:
Get the following permissions from the user and get the user access_token:
manage_pages - to get the page access token
read_insights - to read the impressions (as mentioned in the doc)
read_stream - for all posts that the current session user is able to view
Using that token, get the page access_token with the call-
/{page-id}?fields=access_token
(optional) Check out my answer here to extend this page access token that will never expire. (Basically to avoid some steps)
Using the page access token, run your query-
SELECT post_id, actor_id, message, impressions FROM stream WHERE actor_id = {owned_page} and source_id = {owned_page}
This will fetch you the impressions(if any) in the result.
Hope that helps.!

Error to get friend list of friend of logged in user Facebook php-sdk

I am able to get friend list of friend of logged in user but of limited friends(app users) those having less friends except one friend.
Wait I am explaining in detail.
I am able to get friend list of friends those are app users. My 8 friends are app users. I am able to friends of 7 friends but I am not able to get friends of one friend. One difference found that he is having over 3300 friends others around 300.
I am getting this error
[Fri Mar 02 18:20:44 2012] [error] [client 192.168.1.2] PHP Fatal error: Uncaught Exception: 18: This API call could not be completed due to resource limits\n thrown in /var/www/jobjasoos/system/libraries/base_facebook.php on line 1040
I think it is because of large no. of friends. Is there any way to avoid this error?
I am using this fql query.
$query="SELECT uid, name, work FROM user WHERE is_app_user=1 AND uid IN (SELECT uid2 FROM friend WHERE uid2 IN (SELECT uid2 FROM friend WHERE uid1 = $current_user) ) ORDER BY name";
$user_info=$facebook->api(array('method'=>'fql.query',
'query'=>$query));
And I have seen following links, and didn't got any clue.
Get a list of friends of a friend on Facebook
Why I receive "This API call could not be completed due to resource limits"
How can I optimize my FQL to avoid Facebook timeouts?
Your server is not configured to download a request with so much info. You could try re-configuring your server, but I would suggest redesigning your app instead (if possible). That is, use the JavaScript SDK instead of PHP to get the friends list. This will offload the bandwidth usage from your server to your clients instead. My app uses the JS SDK to download 5000 friends with no problems.
To continue using php, see here:
How can I optimize my FQL to avoid Facebook timeouts?
Write these two lines for avoiding timeouts when calling facebook then call facebook api.
set_time_limit(0);
ini_set("memory_limit", "1024M");
$query="SELECT uid, name, work FROM user WHERE is_app_user=1 AND uid IN (SELECT uid2 FROM friend WHERE uid2 IN (SELECT uid2 FROM friend WHERE uid1 = $current_user) ) ORDER BY name";
$user_info=$facebook->api(array('method'=>'fql.query',
'query'=>$query));
$friends = $facebook->api('me/friends');
//print_r($friends['data']);
print_r("Number of Friends: ". count($friends['data']));
foreach ($friends['data'] as $key=>$listOfFriends) {
echo "<br/>".$key." ".$listOfFriends['name']."<img src='https://graph.facebook.com/".$listOfFriends['id']."/picture' width='50' height='50' title='".$listOfFriends['name']."' />";
}

Unable to Get Correct User Online Presence

I have an app in which I want to check my users' online presence. Right now, when I check, it tells me everyone is offline.
The users grant user_online_presence and offline_access (plus a few other) permissions to the app. Then I store the access token. I am able to access any information I need at any time except for the online presence.
To get the online presence, I first set the access token:
$facebook->setAccessToken($user['AccessToken']);
Then I query Facebook:
$fql = "SELECT uid, name, online_presence, status FROM user WHERE uid = ".$user['FacebookID'];
$param = array('method' => 'fql.query', 'query' => $fql, 'callback' => '');
$fqlResult = $facebook->api($param);
When I check the results, I get the id, name, and status, but everyone is listed as offline, even me when I know I'm online and active:
[online_presence] => offline
Any help getting this working would be greatly appreciated. Thank you all for your time.
I used this FQL query sucessfully :-
SELECT name,online_presence FROM user WHERE uid
IN (SELECT uid2 FROM friend WHERE uid1 = me())
to get all the online friends. Got output as "idle","active" and "offline". All values of which were absolutely correct.
There are 2 permits
user_online_presence, for the user
friends_online_presence, for friends
http://developers.facebook.com/docs/reference/api/permissions/
online_presence is for chat online, not facebook online
The user's Facebook Chat status. Returns a string, one of active,
idle, offline, or error (when Facebook can't determine presence
information on the server side). The query does not return the user's
Facebook Chat status when that information is restricted for privacy
reasons.
Also, I ran fql?q=SELECT name, online_presence FROM user where uid IN (Select uid1 from friend WHERE uid2=me()) and it listed my friend's online status fairly accurately. Only a very few were incorrect. Maybe that's due to a lag in the facebook update system, or maybe they're caching the information for too long, etc.

facebook friends status

i am using this fql query but not getting status its showing null in status for getting facebook friends message please help
SELECT uid, pic_square, name, status FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = 100000660426865)
The query you have built attempts to access your local host SQL server.
Would you like to get status from Facebook directly?
If so, you API provided by Facebook instead.