如何使用 Facebook Graph API 从用户获取特定数据字段?
我正在努力有效地使用 Graph Api。
在为我/朋友访问 facebook 服务器并将所有朋友 ID 解析到字典中(我正在为 Iphone 使用 Objective C 进行开发)后,我想获取有关每个朋友的某些信息。
让我们来看一个收集所有朋友生日的经典示例。注意:我已被授予friends_birthday权限。
以下代码使用 oAuth2Test 框架:
while ((friend_list = (NSDictionary *)[enumerator nextObject])) {
//NSString *name = (NSString *)[friend_list objectForKey:@"name"];
NSString *idd = (NSString *)[friend_list objectForKey:@"name"];
//The following line would return this users birthday along with all the other information the user is allowed to see/has granted permission for.
FbGraphResponse *fb2_graph_response = [fbGraph doGraphGet:idd withGetVars:nil];
}
如何使用字典作为“withGetVars”的参数来仅提取每个用户的生日?
I am struggling to use the Graph Api efficiently.
After hitting the facebook server for me/friends and parsing all friend ID'd into a dictionary (I'm developing in Objective C for the Iphone), I want to get certain info about each friend.
Let's go with a classical example of collecting all of my friends' birthdays. Note: I have been granted the friends_birthday permission.
The following code uses the oAuth2Test Framework:
while ((friend_list = (NSDictionary *)[enumerator nextObject])) {
//NSString *name = (NSString *)[friend_list objectForKey:@"name"];
NSString *idd = (NSString *)[friend_list objectForKey:@"name"];
//The following line would return this users birthday along with all the other information the user is allowed to see/has granted permission for.
FbGraphResponse *fb2_graph_response = [fbGraph doGraphGet:idd withGetVars:nil];
}
How would I use a dictionary as the parameter for "withGetVars" to only pull the birthday for each user?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
获取特定人员的个人资料是一个简单的技巧。不要传递
me/feed
而是传递特定的人员 ID,例如:1234567/feed
,您将获得他的个人资料详细信息。It's simple trick to get the profile of a specific person. Instead of passing
me/feed
pass the specific person ID as eg.1234567/feed
, you will get his profile details.您可以使用
fields=birthday
参数来使用以下图形调用:You can use the following graph call using the
fields=birthday
parameter: