2013-05-08 40 views
1

我想創建一個打開圖形對象,並將用戶生成的照片上載到分段資源中,以便使用它發佈操作。我正在使用iOS的最新Facebook SDK(3.5)。 的代碼如下:用戶圖像作爲打開圖形對象 - iOS

[FBRequestConnection startForUploadStagingResourceWithImage:self.image completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 
     if (!error){ 
      NSString *uri = [result valueForKey:@"uri"]; 

      NSMutableDictionary<FBOpenGraphObject> *object = [FBGraphObject openGraphObjectForPost]; 
      object.provisionedForPost = YES; 
      object[@"type"] = @"<APP_NAME>:<OBJECT_NAME>"; 
      object[@"url"] = uri; 
      object[@"title"] = @"My Title"; 
      object[@"user_generated"] = @"true"; 

      [FBRequestConnection startForPostOpenGraphObject:object 
              completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 

    }]; 
}]; 

startForPostOpenGraphObject結束塊:我應該與新創建的對象的ID來電startForPostWithGraphPath。然而,我沒有身份證,但有一個錯誤:

Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x1f2f14a0 {com.facebook.sdk:HTTPStatusCode=500, com.facebook.sdk:ParsedJSONResponseKey={ 
body =  { 
    error =   { 
     code = 1; 
     message = "An unknown error has occurred."; 
     type = OAuthException; 
    }; 
}; 
code = 500; 
}, com.facebook.sdk:ErrorSessionKey=<FBSession: 0x1f2ca300, state: FBSessionStateOpen, loginHandler: 0x1f2cb750, appID: **************, urlSchemeSuffix: , tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0x1e56ed00>, expirationDate: 4001-01-01 00:00:00 +0000, refreshDate: 2013-05-08 09:07:56 +0000, `attemptedRefreshDate`: 0001-12-30 00:00:00 +0000, permissions:(
"user_photos", 
"publish_stream", 
"publish_actions" 
)>} 

我在做什麼錯?

回答

0

兩個URL和user_generated性質需要圖像屬性,這也是一個數組下得去,所以這樣的事情應該工作:

object[@"type"] = @"<APP_NAME>:<OBJECT_NAME>"; 
object[@"title"] = @"My Title"; 
object[@"image"] = @[@{@"url": uri, @"user_generated":@"true"}]; 

您還可以看到關於如何做美味的樣本它作爲批量請求的一部分。

+0

美味的樣品非常有用。謝謝。 – 2013-05-09 09:18:23