我在Xcode 4.5中创建了一个应用程序。它结合了Facebook登录过程,我的朋友的查询和他们的基本信息以及一些新闻源发布过程的成功。但是,我在尝试查询哪些朋友“喜欢”某个Facebook对象时遇到了问题,在本例中是一张照片。这是我到目前为止所做的:
在 - (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI方法中请求以下权限:user_about_me,read_friendlists,friends_likes,read_stream, friends_likes,user_likes,friends_photos,user_photos。
我去了Facebook,发现了一张我的Facebook好友喜欢的照片。然后,我转到https://graph.facebook.com/?ids=https://www调查了照片的ID。 urlToFBPhoto
我使用了以下查询代码(根据关于此类查询的facebook开发者页面:url)SELECT user_id FROM,如WHERE object_id =“10152365284110475”。
我期待当我从这个查询中得到一个NSLog的结果数据时,我会得到几个我认识的朋友的照片。但相反,查询没有返回任何结果。
为清楚起见,这是我使用的完整查询代码:
- (IBAction)getFriendLikes:(id)sender
NSString *objectID = @"10152365284110475"; //object id of a friend's FB photo
NSString *query = [NSString stringWithFormat:
@"{"
@"'friendlikes':'SELECT user_id FROM like WHERE object_id=%@'," //no data
//@"'friends':'SELECT uid2 FROM friend WHERE uid1 = me()'," //returns data
//@"'friendinfo':'SELECT uid, name, sex, pic_big, pic_square FROM user WHERE uid IN
//(SELECT uid2 FROM #friends)'," //returns data
@"}",objectID];
NSDictionary *queryParam = [NSDictionary dictionaryWithObjectsAndKeys:
query, @"q", nil];
[FBRequestConnection startWithGraphPath:@"/fql"
parameters:queryParam
HTTPMethod:@"GET"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
if (error) {
NSLog(@"Error: %@", [error localizedDescription]);
} else {
NSLog(@"Result: %@", result);
}
NSArray *friendInfo = (NSArray *) [[[result
objectForKey:@"data"]
objectAtIndex:1]
objectForKey:@"fql_result_set"];
[DataController dc].fbArray = nil;
[DataController dc].fbArray = friendInfo;
//post callback tasks
} ];
}
如果有人能提供任何帮助我会非常感激!