2014-04-04 49 views

回答

1

picture參數需要一個有效的網址 @ 「我/飼料」:

-(void)postOnFacebook 
{ 
if (FBSession.activeSession.isOpen) 
    [self postOnWall]; 
else 
{ 
    [FBSession openActiveSessionWithPublishPermissions:[NSArray arrayWithObjects:@"publish_actions", nil] 
             defaultAudience:FBSessionDefaultAudienceEveryone 
              allowLoginUI:YES 
            completionHandler:^(FBSession *session, 
                 FBSessionState status, 
                 NSError *error) 
    { 
     if (error) 
      NSLog(@"Login failed"); 
     else if (FB_ISSESSIONOPENWITHSTATE(status)) 
      [self postOnWall]; 
    }]; 
}; 
} 

- (void)postOnWall 
{ 
FBRequestConnection *newConnection = [[FBRequestConnection alloc] init]; 

FBRequestHandler handler = 
^(FBRequestConnection *connection, id result, NSError *error) { 
    [self requestCompleted:connection forFbID:@"me" result:result error:error]; 
}; 

NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithObjectsAndKeys: 
           @"Test", @"message", 
           @"www.google.com", @"link", 
           [UIImage imageNamed:@"temp.png"], @"picture", 
           @"description", @"description", 
           nil]; 

FBRequest *request=[[FBRequest alloc] initWithSession:FBSession.activeSession graphPath:@"me/feed" parameters:params HTTPMethod:@"POST"]; 
[newConnection addRequest:request completionHandler:handler]; 
[requestConnection cancel]; 
requestConnection = newConnection; 
[newConnection start]; 
} 
0

你應該使用graphPath:@ 「我/照片」,而不是graphPath。有關更多信息,請參閱here

如果您有圖片數據,那麼您首先必須部署該圖片並生成該圖片的鏈接,然後將其提供給picture url

或者,您可以先使用/photos在Facebook上發佈圖像,然後在/feed中使用該圖像。

希望有所幫助。祝你好運!

+0

這是不正確的答案。如果你願意的話,你甚至可以用'feed'添加圖片! –

相關問題