簡體   English   中英

Facebook Graph API朋友生日

[英]Facebook Graph API friends birthdays

我搜索了很多,我沒有成功地結交朋友的生日

[facebook requestWithGraphPath:@"me" andDelegate:self];

我應該寫什么而不是我來結交朋友的生日。 謝謝

試試以下內容:

[facebook requestWithGraphPath:@"me/friends" 
                         andParams:[ NSDictionary dictionaryWithObjectsAndKeys:@"picture,id,name,link,gender,last_name,first_name",@"fields",nil]
                       andDelegate:self];

查詢/困難時請告訴我。

有時,生日值將類似於“空”或僅“月份和日期”或“完整日期”。 所以你必須手動檢查它。

我有一個要求,我必須只顯示月份和日期。

你可以從下面的功能檢查它:

+(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;
} 

這里,“pstrDate”日期值是Facebook的生日日期值。

我希望它對你有所幫助。

干杯。

使用graph api獲取friends_birthday:

[facebook requestWithGraphPath:@"me/friends?fields=id,name,gender,picture,birthday" andDelegate:self];

並添加如下權限:

_permissions = [[NSArray arrayWithObjects:
                     @"read_friendlists",@"publish_stream ,user_checkins", 
                     @"friends_checkins", @"publish_checkins",@"email", nil] 
                 retain];

我找到了答案,它如下:

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