0

我正在使用 FQL 来确定用户是否喜欢某个帖子。当用户没有喜欢任何帖子时,响应已经足够好,但是当帖子被点赞时它保持不变,我没有得到用户(我的)user_id的响应。

这是我所做的:(在获得read_stream许可后在授予的块内)

NSURL *requestURL = [NSURL URLWithString:@"https://graph.facebook.com/fql"];
    NSMutableDictionary * params = [NSMutableDictionary
                                    dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"select user_id from like where object_id=%@ AND user_id=me()",postID], @"q", nil];
    SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook
                                            requestMethod:SLRequestMethodGET
                                                      URL:requestURL
                                               parameters:params];
    request.account = [[self.accountStore accountsWithAccountType:accountTypeFacebook] objectAtIndex:0];
    [request performRequestWithHandler:^(NSData *data,
                                         NSHTTPURLResponse *response,
                                         NSError *error) {

        if(!error){
            NSDictionary *resultDictionary = [[NSDictionary alloc] init];
            resultDictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
            NSLog(@"dictionary with user id's: %@",resultDictionary);
        }else{
          //handle error gracefully
        }
     }];

输出(不喜欢帖子时):

{
    data =     (
    );
}

输出(当帖子被喜欢时):

{
    data =     (
    );
}

我尝试使用post_idinplace of传递帖子的 id 和查询object_id,但没有成功。

4

1 回答 1

1

To check whether user liked a post we need to get data form stream table instead of like table, please follow the below request

Request : 
NSURL *requestURL = [NSURL URLWithString:@"https://graph.facebook.com/fql"];
                                                       NSMutableDictionary * params1 = [NSMutableDictionary
                                                                                        dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"SELECT likes FROM stream WHERE post_id = '%@'",postID], @"q",facebookOfflineAccessToken,@"accessToken",nil];

Response : you will get "user_likes" = 0 for not liked,"user_likes" = 1 for like

于 2014-02-28T12:51:16.177 回答