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.
Related
Hello I'm trying to run a FQL multiquery in python 3 and failing miserably. I can run 1 query fine however when I'm trying to run a multiquery I can't get it to work. For the sake of this question I've just used a multiquery that I;ve found online.
import urllib.request
import urllib.parse
ACCESS_TOKEN = 'xxxxxxxxxxxxxxxxx'
query1 = "SELECT sex FROM user WHERE uid=me()"
query2 = "SELECT uid, name, sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND not (sex in (select sex from #user_sex)) ORDER BY name"
query = {'query1':query1,'query2':query2}
params = urllib.parse.urlencode({'q': query, 'access_token': ACCESS_TOKEN})
#print (params)
url = "https://graph.facebook.com/fql?" + params
print (url)
data = urllib.request.urlopen(url).read()
print(data)
As #CBroe said, it doesn't make sense to use FQL anymore... You can get this info in one pass with the Graph API:
GET /me?fields=gender,friends{id,name,gender}
Be aware that your friends need to use the app too, otherwise you'll not be able to retrieve their info.
How to get a list of friends who play in my game or who install my game?
This code is not working:
string fql = "/fql?q=SELECT uid, name, is_app_user, pic_square FROM user WHERE uid IN "+
"(SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user = 1";
FB.API(fql, Facebook.HttpMethod.GET, GetListOfPlayer);
You're query is absolutely correct. I'm not sure but the problem could be that you have not urlencoded the fql query.
You can try this-
string query = WWW.EscapeURL("SELECT uid, name, is_app_user, pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user = 1");
string fql = "/fql?q="+query;
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'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];