2012-08-30 68 views
3

尝试发布到用户的Facebook墙时出现以下错误,我似乎无法找到源。任何人都有这方面的见解?当发布到用户的墙上时,Facebook SDK API IOS错误

2012-08-29 22:14:38.490 CanP[405:707] Error: HTTP status code: 400 
2012-08-29 22:14:38.494 CanP[405:707] FBSDKLog: Response <#1111> <Error>: 
The operation couldn’t be completed. (com.facebook.sdk error 5.) 

时运行的方法应该张贴讯息facebook的墙上如下:

[FBSettings setLoggingBehavior:[NSSet setWithObjects: 
           FBLoggingBehaviorFBRequests, 
           nil]]; 
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
[defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"]; 
[defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"]; 
[defaults synchronize]; 

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
           @"My test app", @"name", 
           @"http://www.google.com", @"link", 
           @"FBTestApp app for iPhone!", @"caption", 
           @"This is a description of my app", @"description", 
           @"Hello!\n\nThis is a test message\nfrom my test iPhone app!", @"message", 
           nil]; 

// Publish. 
// This is the most important method that you call. It does the actual job, the message posting. 
[facebook requestWithGraphPath:@"me/feed" andParams:params andHttpMethod:@"POST" andDelegate:self]; 
+1

我跟着[相同的教程](http://gabriel-tips.blogspot.nl/2011/10/how-to-post-on-facebook-wall-through.html),我有同样的错误。 – sixstatesaway

回答

1

我会建议你使用新的SDK 3.1方法张贴。

[FBRequestConnection 
startWithGraphPath:@"me/feed" 
parameters:params 
HTTPMethod:@"POST" 
completionHandler:^(FBRequestConnection *connection, 
        id result, 
        NSError *error) { 
    if (error) { 
     /* Handle error */ 
    } else { 
     /* Handle success */ 
    } 
}]; 

对于教程一步一步,请参阅:https://developers.facebook.com/docs/howtos/publish-to-feed-ios-sdk/

还要确保你问publish_action权限首先要确保你可以张贴在墙上。

如果仍然遇到问题,请在错误行中放置断点并查看错误变量,然后深入到名为userInfo的字典中,该字典应包含更易读的错误消息。

+0

非常感谢。 userInfo字典真的是解决这些问题的关键。 – Arman

2

正如C Abernathy所建议的那样,您应该“在错误行放置一个断点并查看错误变量,然后深入到名为userInfo的字典中,该字典应包含更多可读的错误消息。”

对于我们测试新的Facebook的整合,最常见的问题很可能是要显示的error.userInfo"com.facebook.sdk.ParsedJSONResponseKey"

message = "(#506) Duplicate status message"; 

会发生变化,你用它来测试你的Facebook的整合文字,和你可能会发现你的代码工作得很好!

+0

userInfo是黄金,谢谢。至少你知道为什么不工作而不是盲目地修理它。 –

相关问题