升級我的應用程序。目標是iOS5.1。 Xcode 4.5.2以及使用FacebookSDK 3.0和Twitter框架。 應用程序正在登錄Facebook沒有問題。當我嘗試發佈一個帖子,我得到這個返回的日誌中:iOS:Facebook錯誤「缺少消息或附件」
2012-12-18 10:39:31.934 MyApp[31754:1d603] Error Domain=com.facebook.sdk Code=5
"The operation couldn’t be completed. (com.facebook.sdk error 5.)"
UserInfo=0xab74630 {com.facebook.sdk:ParsedJSONResponseKey={
body = {
error = {
code = 100;
message = "(#100) Missing message or attachment";
type = OAuthException;
};
};
code = 400;
}, com.facebook.sdk:HTTPStatusCode=400}
2012-12-18 10:39:31.935 MyApp[31754:1d603] (null)
最後一行是一個數表達列出「postParams」在下面列出的「publishStory」方法的結果。請注意它是(null)。 模擬器中的錯誤結果是「錯誤:域= com.facebook.sdk,代碼= 5」
我使用Facebook教程來構建FB接口。正如本教程所示,我已經列出了initWithNibName中列出的參數。
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// this stuff will change... just get it working
self.postParams = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
@"Share...", @"message",
@"http://MyApp.com", @"link",
@"icon.png", @"picture",
@"MyApp", @"name",
@"A wonderful way to record your life events.", "caption",
@"Easy to use.", @"description",
nil];
}
return self;
}
然後,「發佈」是在一個單獨的方法,這是它停止,我得到上述錯誤。
- (void)publishStory
{
[FBRequestConnection
startWithGraphPath:@"me/feed"
parameters:_postParams
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
NSString *alertText;
if (error) {
NSLog(@"%@",error);
NSLog(@"%@", _postParams);
alertText = [NSString stringWithFormat:
@"error: domain = %@, code = %d",
error.domain, error.code];
} else {
alertText = [NSString stringWithFormat:
@"Posted action, id: %@",
[result objectForKey:@"id"]];
}
// Show the result in an alert
[[[UIAlertView alloc] initWithTitle:@"Result"
message:alertText
delegate:self
cancelButtonTitle:@"OK!"
otherButtonTitles:nil]
show];
}];
}
我認爲,實際參數沒有被上傳。我一直在尋找幾天試圖找到解決方案。 任何人都有如何解決這個問題,並獲得完成後的想法?任何幫助將不勝感激!