How am I able to see which of my friends attend a Facebook event? I'm able to get a list of all attendees using the Facebook SDK, withGraphPath:#"eventId/attending/".
Is what I want even possible using the Graph API? I read some answers on how to achieve this with FQL but don't know how to implement it in iOS. The only option I came up with is getting all friends and all attendees and cross-referencing them against each other, but that is very inconvenient.
So, how do I get only MY Facebook friends attending an event?
This is from the tutorial provided by Facebook
You can check if a specific user responded 'yes' to an event by
issuing an HTTP GET to /EVENT_ID/attending/USER_ID. These operations
require the user_events or friends_events permissions for non-public
events and return an array of objects with the name, id, and
rsvp_status fields. When checking a single user, an empty data will be
returned if the user did not respond 'yes' to the event.
You can check it by checking the event category in this link:
http://developers.facebook.com/docs/reference/api/event/
Use /EVENT_ID/attending/USER_ID to see which friend is attending to an event
Okay, so I found the solution to my problem... The only way to achieve what I want is through FQL. Basically, it cross-references your friends with the attendees but on the Facebook servers, and you only receive the data you ask for (in my case user ID, name, image). I have not figured out how to set a limit and offset, but I don't require it and I think it is possible via FQL too...
Here is my code:
-(void)getFriendsAttending{
NSLog(#"getting friends");
NSString *fql = [NSString stringWithFormat:#"SELECT uid, name, pic FROM user WHERE uid IN (SELECT uid FROM event_member WHERE eid = %# AND rsvp_status = 'attending' AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me()))", fbID];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObject:fql forKey:#"q"];
[FBRequestConnection startWithGraphPath:#"/fql"
parameters:params
HTTPMethod:#"GET"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
if (error) {
NSLog(#"Error: %#", [error localizedDescription]);
} else {
NSLog(#"Friends at event %#: %#", fbID, result);
}
}];
}
And here is the pure FQL query for clarity (123456789 - being the event ID):
SELECT uid, name, pic FROM user WHERE uid IN (SELECT uid FROM event_member WHERE eid = 123456789 AND rsvp_status = 'attending' AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me()))
Just utilize the {event id}/attending and then filter this based on your actual friends list.
Using FQL QUery try:
SELECT uid FROM event_member WHERE eid = YOU_EVENT_ID_HERE AND rsvp_status = 'attending'
Using Graph API:
/YOU_EVENT_ID_HERE/attending
This returns the "Attending Friends" user ID's (uid).
ASH
Hi i want to get list of my fabebook friend ids with paging of 100 users.
The problem is that if i set hte FQL to
NSString *fqlString = #"SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) LIMIT 300";
It returns me as expected the only first 300 users in the table with out any reference to next page.
Result: {
data = (
{
uid = 1519xxx;
},
{
uid = 9806xxx;
}
....
);
}
if i request friends with [FBRequest requestForMyFriends] it returns me all of my friends and additionaly a paging key with the url object for next page.
The question is how can i tell with FQL to give me lists of 100 users with paging to next 100 users.
The Graph API returns paging links; FQL does not. So you’d have to do that yourself, by making another query including an OFFSET parameter.
I need fetch user's friends data with next fields: id, name,
gender, birthday, city, country, profileUrl, pic, pic_small,
pic_big, is_app_user.
Before I used FB.Data.query, but now it's deprecated.
FB.Data.query('select uid, first_name, last_name, name, pic,
pic_small, pic_big, birthday_date, sex, current_location,
profile_url, is_app_user from user where uid in (select uid2 from
friend where uid1 = {0}', uid).
How to fetch friends, who are using app?
I can get all fields what i need, but for example for pictures i need to do additional requests. Can i get all needed fields in single request?
You can still use same FQL query with Graph API and JavaScript SDK
var query = 'SELECT uid, first_name, last_name, name, pic, pic_small, pic_big, birthday_date, sex, current_location, profile_url, is_app_user FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = ' + uid;
FB.api('/fql',{q:query}, function(response){
console.log(response.data);
});
You for sure can also get almost same data with Graph API not using FQL at all:
FB.api('/'+uid+'/friends', {
fields: 'id,first_name,last_name,name,birthday,gender,location,link,installed'
}, function(response){
console.log(response.data);
});
You have a bit different names and other format (ex location) for those details and miss the picture details in results but this is simple, user picture is available on URL in form http://graph.facebook.com/USER_ID/picture
use ?type=square | small | normal | large to request a different photo
I've been poking around with this too, using PHP. This is what I came up with:
$user_friends = $facebook->api('/me/friends?fields=installed');
$user_players = array();
foreach ($user_friends['data'] as $userfriend)
{
if (array_key_exists('installed', $userfriend))
{
array_push($user_players, $userfriend);
}
}
The Following Helps you to fetch user's friend details using graph api
NSString friendId =10020020 //Store Friend ID;
NSString * pRequestString = [NSString stringWithFormat:#"%#?fields=name,picture,work,hometown,birthday,devices,interests",friendId];
[[FBRequest requestForGraphPath:pRequestString ] startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSLog(#"%#",result);
}];
I am executing this query in FQL [#"SELECT likes,message,actor_id FROM stream WHERE source_id = %lld limit 50", _session.uid]. It is giving result well but I want to fetch my friends name also. I don't want to execute query within loop to fetch friends name from their profile. If it is possible in multiquery then which type of query I will have to write?
I use this code:
NSString* fql = [NSString stringWithFormat:#"SELECT uid,name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = %lld)", session.uid];
Hope it can give you a hint.
I'm trying to get a list of user's friends using fb connect for the iphone.
I've tried both of the following FQL Queries, but they don't seem to be returning anything.
which one is correct if any ?
NSString* fql = [NSString stringWithFormat:#"select flid,name from friendlist where owner=%lld",[self fbSession].uid];
or
NSString* fql = [NSString stringWithFormat:#"SELECT flid,uid FROM friendlist_member WHERE flid IN (SELECT flid FROM friendlist WHERE owner=%lld)",[self fbSession].uid];
Ah.. figured it out...
NSString* fql = [NSString stringWithFormat:#"SELECT name,uid FROM user WHERE uid IN ( SELECT uid2 FROM friend WHERE uid1=%lld )",[self fbSession].uid];