我想获取Facebook登录用户的兴趣和喜欢,我能够做到。 但是我没有得到用户或图片所喜欢的页面的图像以供用户使用。
以下代码可让我抓取用户喜欢的内容:
[FBRequestConnection startWithGraphPath:@"/me/likes"
parameters:nil
HTTPMethod:@"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
NSLog(@"User interests data: %@",result);
}];
返回以下json数据:
data = (
{
category = "Musician/band";
"created_time" = "2014-08-08T05:09:56+0000";
id = 9770929278;
name = Adele;
},
{
category = "Musician/band";
"created_time" = "2014-08-08T05:02:09+0000";
id = 5027904559;
name = Shakira;
}
);
但是,我想要想要的页面的图像。我怎样才能做到这一点? 任何帮助,将不胜感激。 提前谢谢。
答案 0 :(得分:2)
您可以为喜欢的人执行另外一个Graph API调用:
[FBRequestConnection startWithGraphPath:@"/me/likes"
parameters:nil
HTTPMethod:@"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
NSArray *data = [result objectForKey:@"data"];
for(NSDictionary *liked in data) {
NSString *page_id = [liked objectForKey:@"id"];
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"/%@/picture", page_id] parameters:nil HTTPMethod:@"GET" completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
// Get your profile pic here
}
}];
}
}];
它将返回Page的公开详情。有关详细信息,请参阅documentation。