2014-01-13 23 views
1

我正在尝试在应用程序中实现“喜欢某个状态”。我使用Facebook的SDK引用,并都拿出了这段代码:使用og_likes喜欢Facebook状态iOS功能错误

- (void) likeAStatus : (NSString *) postId { 
NSString *post = [NSString stringWithFormat:@"http://facebook.com/%@", postId]; 

NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys: 
         post, @"object", 
         nil 
         ]; 
/* make the API call */ 
[FBRequestConnection startWithGraphPath:@"/me/og.likes" 
          parameters:params 
          HTTPMethod:@"POST" 
         completionHandler:^(
              FBRequestConnection *connection, 
              id result, 
              NSError *error 
             ) { 
          NSLog(@"Result is %@", result); 
          NSLog(@"Error is %@", error); 

          NSString *idFromCreate = [NSString stringWithFormat:@"/%@", [result objectForKey:@"id"]]; 

          /* make the API call */ 
          [FBRequestConnection startWithGraphPath:idFromCreate 
                 parameters:params 
                 HTTPMethod:@"POST" 
               completionHandler:^(
                    FBRequestConnection *connection, 
                    id result, 
                    NSError *error 
                    ) { 
                NSLog(@"Result is %@", result); 
                NSLog(@"Error is %@", error); 
               }]; 
         }]; 
} 

现在,当我上,我没有喜欢以前的帖子(我只是有编码的帖子ID现在)这个运行我在控制台中这样的响应:(我只是打印动作ID,以确保它被解析正确响应)

2014-01-13 15:59:43.766 Unifeed[5336:70b] Result is { 
    id = 10151765515511916; 
} 
2014-01-13 15:59:43.767 Unifeed[5336:70b] Error is (null) 
2014-01-13 15:59:43.767 Unifeed[5336:70b] The ID is /10151765515511916 
2014-01-13 15:59:44.052 Unifeed[5336:70b] Result is { 
    "FACEBOOK_NON_JSON_RESULT" = true; 
} 
2014-01-13 15:59:44.053 Unifeed[5336:70b] Error is (null) 

这看起来像它的工作原理,不幸的是,当我去检查我的Facebook,并期待在这个特定的职位,它是不喜欢的....如果我检查我在Facebook上的活动日志,我没有看到我喜欢这个状态。

任何有关正在进行的任何想法或对不同的喜欢状态更新方法的建议?也是“FACEBOOK_NON_JSON_RESULT”=真是件好事?

非常感谢!

回答

1

我已经想通了 - 这是图API调用的区别。现在代码看起来像这样:

- (void) likeAStatus : (NSString *) postId { 
NSString *post = [NSString stringWithFormat:@"%@/likes", postId]; 

/* make the API call */ 
[FBRequestConnection startWithGraphPath: post 
          parameters:nil 
          HTTPMethod:@"POST" 
         completionHandler:^(
              FBRequestConnection *connection, 
              id result, 
              NSError *error 
             ) { 
          NSLog(@"Result is %@", result); 
          NSLog(@"Error is %@", error); 
         }]; 
} 

希望这可以帮助别人在未来!

Andy