简体   繁体   English

Facebook Graph API朋友生日

[英]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. 这里,“pstrDate”日期值是Facebook的生日日期值。

I hope it will be helpful to you. 我希望它对你有所帮助。

Cheers. 干杯。

Get friends_birthday using graph api: 使用graph api获取friends_birthday:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM