2011-12-27 91 views
3

我搜索了很多,我沒有成功地得到了朋友的生日Facebook的圖形API朋友生日

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

我應該怎麼寫的,而不是我得到朋友的生日。 感謝

下面

回答

2

我找到了答案&它如下:

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

恭喜!你的回答幫助我了!這有助於幫助我的朋友和他幫助其他人:D:P –

3

嘗試:

[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的生日日期值。

我希望這對你有幫助。

乾杯。

2

獲取friends_birthday使用圖形API:

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