如何从facebook获取生日列表

时间:2012-04-17 10:56:08

标签: iphone facebook

我正在开发一个应用程序,我想展示一个朋友的生日。这可能吗?  如何从Facebook获得朋友的出生日期?

3 个答案:

答案 0 :(得分:1)

你必须要求许可,如: -

在.h文件中定义宏,如: -

#define kFBPermission @"@\"offline_access\", @\"publish_stream\",@\"friend_birthday\",@\"user_events\",@\"read_stream\",@\"friends_likes\""

现在在.h文件中,write.objDelegate是AppDelegate类的对象。

if (![objDelegate.facebook isSessionValid])
    {
    [objDelegate.facebook authorize:App_ID permissions:[NSArray arrayWithObjects:@"offline_access",@"publish_stream",@"friends_birthday",@"user_events",@"read_stream",@"friends_likes", nil] delegate:self];
    }

要在标签中显示生日,请使用: -

[lblDOB setText:[NSString stringWithFormat:[self.friendDictionary valueForKey:@"birthday"]]];

希望它有所帮助。谢谢:)

答案 1 :(得分:0)

默认情况下,进行查询时会返回大多数对象属性。您可以使用“fields”查询参数选择要返回的字段(或连接)。例如,此网址只会返回Ben:https://graph.facebook.com/bgolub?fields=id,name,picture

的ID,名称和图片

您还可以使用“ids”查询参数在单个查询中请求多个对象。例如,网址https://graph.facebook.com?ids=arjun,vernal会在同一响应中返回两个配置文件。

“ids”查询参数也接受网址。这对于在Open Graph中查找URL的ID非常有用。例如:https://graph.facebook.com/?ids=http://www.imdb.com/title/tt0117500/

此外,还有一个特殊的标识符,它指的是当前用户。因此,网址https://graph.facebook.com/me会返回活动用户的个人资料。

通过/ home,/ feed或/ posts连接检索帖子时,您可以通过在URL参数中添加= location来将结果限制为只有附加位置的帖子: https://graph.facebook.com/me/home?with=location

答案 2 :(得分:0)

从Facebook帐号获取朋友生日使用Facebook连接。

这里是您必须触发查询的代码,如下所示,以获取朋友信息。

    - (IBAction)getFriends {

        [self initFacebook];

        if ([facebook isSessionValid]) {

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

            } else {

            [self loginToFacebook];

            }
         }