2012-12-18 86 views
0

升級我的應用程序。目標是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]; 
    }]; 
} 

我認爲,實際參數沒有被上傳。我一直在尋找幾天試圖找到解決方案。 任何人都有如何解決這個問題,並獲得完成後的想法?任何幫助將不勝感激!

回答

1

我有一個類似的問題,但我的問題是,postParams不保留,因爲我沒有使用屬性,我在同一個發佈方法中創建postParams。我需要在課堂上保留一些參數。

確保您的財產正在使用retain,並確保正在調用init方法。

相關問題