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

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!

Related

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

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.

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];

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!

Facebook FQL multiquery in iOS SDK

I am looking for some documentation or sample code on how to send multiquery fql requests to Facebook via iOS SDK.
I found some older samples but they doesnt work for me.
I have populated an NSDictionary with the queries and I try to send the request via
[[FBRequest requestWithDelegate:self] call:#"facebook.fql.multiquery" params:params];, as stated in the samples I have read, but I get an "unrecognized selector sent to class" error and I cant find the "requestWithDelegate" method in FBRequest.h either. Is it deprecated?
Some help on this would be very appreciated!
// Construct your FQL Query
NSString* fql = [NSString stringWithFormat:#"SELECT uid, name, hometown_location from user where uid IN (SELECT uid2 FROM friend WHERE uid1=%lld) and hometown_location != '' ORDER BY rand() limit 4", facebookId];
// Create a params dictionary
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObject:fql forKey:#"query"];
// Make the request
[facebook requestWithMethodName:#"fql.query" andParams:params andHttpMethod:#"GET" andDelegate:self];
The the delegate FBRequestDelegate will be call with the response. Depending on your needs, you'll do something like:
- (void)request:(FBRequest*)request didLoad:(id)result {
NSLog(#"didLoad() received result: %#", result);
}
The facebook object is created like:
Facebook * facebook = [[Facebook alloc] initWithAppId:kAppID];
More info on how to set this up can be found here:
https://developers.facebook.com/docs/guides/mobile/
And depending on your FQL query, you will need permissions from the user. See the list of permissions here:
https://developers.facebook.com/docs/authentication/permissions/
There is also a test console for FQL queries here:
https://developers.facebook.com/docs/reference/rest/fql.query/
And if you want to do an Multiquery instead of a single query, it would look like:
NSString* fql1 = [NSString stringWithFormat:
#"select uid2 from friend where uid1 == %lld order by rand() limit 10", facebookId];
NSString* fql2 = [NSString stringWithFormat:
#"select uid, name from user where uid in (select uid2 from #queryID)"];
NSString* fql3 = [NSString stringWithFormat:
#"select uid, status_id, message from status where uid in (select uid from #queryName) limit 1"];
NSString* fql = [NSString stringWithFormat:
#"{\"queryID\":\"%#\",\"queryName\":\"%#\",\"queryStatus\":\"%#\"}",fql1,fql2,fql3];
NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:#"queries"];
[facebook call:#"fql.multiquery" params:params];

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!!!