getting birth_day=Null from facebook API's - iphone

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

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

Facebook Graph API friends birthdays

I searched a lot, I didn't succeeded in getting the friends birthday
[facebook requestWithGraphPath:#"me" andDelegate:self];
what should I write instead of me to get the friends birthdays.
thanks
Try with below:
[facebook requestWithGraphPath:#"me/friends"
andParams:[ NSDictionary dictionaryWithObjectsAndKeys:#"picture,id,name,link,gender,last_name,first_name",#"fields",nil]
andDelegate:self];
Let me know in case of query/difficulty.
Sometimes,
Birthday value will be like "null" or only "month & date" or the "full date". So you have to check it manually.
I have one requirement in which I have to display only Month & Date.
You can check it from below function:
+(NSString *)getShortDate:(NSString *)pstrDate{
NSArray *arrayDateData = [pstrDate componentsSeparatedByString:#"/"];
NSString *strShortDate = #"";
if([arrayDateData count]>=2){
strShortDate = [NSString stringWithFormat:#"%#/%#", [arrayDateData objectAtIndex:0], [arrayDateData objectAtIndex:1]];
}
return strShortDate;
}
Here, "pstrDate" date value is Facebook birthday date value.
I hope it will be helpful to you.
Cheers.
I found an answer & it is as follows:
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];
Get friends_birthday using graph api:
[facebook requestWithGraphPath:#"me/friends?fields=id,name,gender,picture,birthday" andDelegate:self];
and add permissions like this:
_permissions = [[NSArray arrayWithObjects:
#"read_friendlists",#"publish_stream ,user_checkins",
#"friends_checkins", #"publish_checkins",#"email", nil]
retain];

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!

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