Facebook Graph API friends birthdays - iphone

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

Related

How to make a friend request with facebook ios sdk?

i'm using the facebook iOS sdk.
I need to send friend requests between users of facebook, from an iOS app.
I know that can not be sent via graph API. I'm trying to through dialog of facebook i do not know how.
Can anyone help me?
This is my code:
Facebook *face = [[Facebook alloc] initWithAppId:#"APP_ID" andDelegate:self];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"user_id", #"id",
nil];
[face dialog:#"me/friends"
andParams:params
andDelegate:self];
With this code i get a dialog with this text: "The page you requested was not found"
Ok I found a solution.
I have created a NSMutableDictionary to make a "appRequest" with their corresponding parameters but finally indicated that the type of dialogue is a "friends".
It's a strange solution but it works.
Facebook *face = [[Facebook alloc] initWithAppId:FBSession.activeSession.appID andDelegate:nil];
face.accessToken = FBSession.activeSession.accessToken;
face.expirationDate = FBSession.activeSession.expirationDate;
if ([face isSessionValid]){
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"My Title", #"title",
#"Come check out my app.", #"message",
userId, #"id",
nil];
[face dialog:#"friends"
andParams:[params mutableCopy]
andDelegate:nil];
}
This may help you
NSDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys: message, #"message", title, #"title", nil];
[[self facebook] dialog: #"apprequests"
andParams: [params mutableCopy]
andDelegate: delegate];
See this question for further details and also this document.

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.

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

Tagging Photos via Facebook GraphAPI

Facebook recently added photo-tagging capabilities to its Graph API:
http://developers.facebook.com/blog/post/509/
I am using FbConnect on iPhone to upload a picture and tag my page inside it.
So, my first call is:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
self.imageToPost, #"picture",
#"My caption!", #"name", #"tags",
nil];
[self.theFacebook requestWithGraphPath:#"me/photos"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
This correctly returns:
{
id = 2092859844825;
}
Then I make another call:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
FACEBOOK_PAGE_ID,#"to",
#"160",#"x",
#"240",#"y",
nil];
[self.theFacebook requestWithGraphPath:[NSString stringWithFormat:#"%#/tags",photoId]
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
Then I get:
{contents = "OAuthException"}
{contents = "(#121) Invalid photo id"}
But what ID does it expect from me?
Submitting the same request in GET method, it doesn't give the error, so I think the id is correct. Any ideas??
What permissions do you have set? Check you have the user_photos permission

FQL and using its result

how can we use the result that we get from FQL
specifically
how can we use the result to save it in another array
take in consideration that for iOS
an example:
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"SELECT uid,name FROM user WHERE uid=4", #"query",
nil];
[facebook requestWithMethodName: #"fql.query"
andParams: params
andHttpMethod: #"POST"
andDelegate: self];