How to get Facebook friends online status in iphone using Graph API.? - iphone

I am trying to get the list of all online friends using Graph API.
I am using the following..
[facebook requestWithGraphPath:#"me/friends?fields=id,name,online_presence" andDelegate:self];
but this gives me 0 results.
Thanks.
EDIT:
I already have the permissions for doing this from FB.

If you have the friends_online_presence permission correctly configured, try this:
NSString* method = #"fql.query";
NSString* fql = #"SELECT uid, online_presence FROM user WHERE uid IN (SELECT uid2 FROM friend where uid1 = me())";
NSDictionary* params = [NSDictionary dictionaryWithObject: fql forKey: #"query"];
[[self facebook] requestWithMethodName: method
andParams: [params mutableCopy]
andHttpMethod: #"GET"
andDelegate: delegate];
This will return you a list of friends with online presence: active, idle, offline or error.

Related

iPhone app: find the Facebook friends who has installed app into their device

I am implementing iPhone app where I want to fetch list of friends from Facebook who has already installed the app into their devices.
For that I'm sending request as below:
AppDelegate *appDelegate=[[UIApplication sharedApplication] delegate];
NSMutableDictionary*params = [NSMutableDictionary dictionaryWithObjectsAndKeys:#"picture,id,name,link,gender,last_name,first_name",#"fields", nil];
[[appDelegate facebook] requestWithMethodName:#"friends.getAppUsers" andParams:params andHttpMethod:#"GET" andDelegate:self];
but in response it is giving me only Facebook id of users who has installed app into their device as:
xxxxxxxxxxxxxx1,
xxxxxxxxxxxxxx2,
xxxxxxxxxxxxxx3
How can I receive response as below for all friends who are using app?
{
"first_name" = abc;
gender = male;
id = 10000xxxxxxxxxxxx;
"last_name" = xyz;
link = "http://www.facebook.com/profile.php?id=10000xxxxxxxxxxxx";
name = "abc xyz";
picture = "http://profile.ak.fbcdn.net/static-ak/rsrc.php/v2/yo/r/UlIqmHJn-SK.gif";
}
How can I achieve that?
using FQL I could get response with parameter is_app_use in Query
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"select uid, name,pic_small, is_app_user from user where uid in (select uid2 from friend where uid1=me()) and is_app_user=1", #"query",
nil];
[[APPDELEGATE facebook ] requestWithMethodName: #"fql.query"
andParams: params
andHttpMethod: #"POST"
andDelegate: self];

getting birth_day=Null from facebook API's

NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"select uid,name,birthday_date from user where uid in (select uid2 from friend where uid1=me())", #"query",
nil];
[[StaticFacebook getFacebook] requestWithMethodName: #"fql.query"
andParams: params
andHttpMethod: #"POST"
andDelegate: self]
;
i am using the above code to get friends info.....
but the problem is that i am getting birth_day="null"
please sugget me the solution.......
thaks in advance.....
Make sure you have requested the proper access permissions to retrieve the birthday field.
user_birthday - Provides access to the birthday with year as the birthday property
Reference: https://developers.facebook.com/docs/authentication/permissions/
Access birthday permission like this ..
[facebookObj authorize:App_ID permissions:[NSArray arrayWithObjects:#"offline_access",#"publish_stream",#"user_birthday",#"user_events",#"read_stream",#"friends_likes", nil] delegate:self];

how to get friends profile image in friend list of facebook

I am creating a iPhone app in which i have to show friend list with their images.
I am using Facebook graph api. i am getting the friends id and name but not the images.
So please suggest me how i can get this?
Write a FQL to get list of facebook friends & their Pics
NSString *query = #"SELECT uid,name,first_name,last_name,pic_square FROM user WHERE uid IN (";
query = [query stringByAppendingFormat:#"SELECT uid2 FROM friend WHERE uid1 = %#)",userid];
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
query, #"query",
nil];
[_facebook requestWithMethodName: #"fql.query"
andParams: params
andHttpMethod: #"POST"
andDelegate:self];
you will get a array in u r
-(void)request:(FBRequest *)request didLoad:(id)result
Sample
{
"first_name" =User;
"last_name" = R;
name = "User R";
"pic_square" = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash2/.jpg";
uid = 595sd1;
}
{},{} etc
Hope this helps!

profile pic(thumbnail) of friends using graph api in facebook

Have a simple problem to load my friend list in table view and asynchronously load their profile-pic thumbnails. I just couldn't figure out the correct url for the thumbnail image. could anyone help me out with the url of the display pic of friends
Write a FQL to get list of facebook friends & their Pics
NSString *query = #"SELECT uid,name,first_name,last_name,pic_square FROM user WHERE uid IN (";
query = [query stringByAppendingFormat:#"SELECT uid2 FROM friend WHERE uid1 = %#)",userid];
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
query, #"query",
nil];
[_facebook requestWithMethodName: #"fql.query"
andParams: params
andHttpMethod: #"POST"
andDelegate:self];
you will get a array in u r
-(void)request:(FBRequest *)request didLoad:(id)result
Sample
{
"first_name" =User;
"last_name" = R;
name = "User R";
"pic_square" = "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash2/.jpg";
uid = 595sd1;
}
{},{} etc
Hope this helps!

How do I retrieve a friend list from Facebook and show it in a table view?

How do I retrieve a friend list from Facebook and show it in a table view in iOS?
Hii,
Write a FQL to extract User friend List,
NSString *query = #"SELECT uid, name, pic_square, status FROM user WHERE uid IN (";
query = [query stringByAppendingFormat:#"SELECT uid2 FROM friend WHERE uid1 = %#)",self.uid];
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
query, #"query",
nil];
[_facebook requestWithMethodName: #"fql.query"
andParams: params
andHttpMethod: #"POST"
andDelegate: self];
Hope this Helps!!!