2015-11-06 88 views
0

我想從我的iOS應用向Facebook上傳視頻和我使用的代碼:的iOS FacebookSDK視頻上傳

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"mp4"]; 
NSData *videoData = [NSData dataWithContentsOfFile:filePath]; 
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
           videoData, @"video.mp4", 
           @"video/mp4", @"contentType", 
           @"Video Test Title", @"title", 
           @"Video Test Description", @"description", 
           nil]; 
[FBRequestConnection startWithGraphPath:@"me/videos" 
         completionHandler:^(FBRequestConnection *connection, 
              id result, NSError *error) 
{ 
    [FBRequestConnection startWithGraphPath:@"me/videos" 
            parameters:params 
            HTTPMethod:@"POST" 
          completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 
           if(!error) 
           { 
            NSLog(@"SUCCESS RESULT: %@", result); 
           } 
           else 
           { 
            NSLog(@"ERROR: %@", error.localizedDescription); 
           } 

}]; 

但我得到的錯誤:

FBSDKLog:錯誤的請求到端點「我/視頻」:必須爲打到此端點的呼叫指定一個打開的FBSession。

錯誤:操作無法完成。 (com.facebook.sdk錯誤5.)

任何人都可以幫我嗎?

+0

您是否設法解決此問題? –

+0

我無法解決問題 – Rupshikha

回答

0

登錄訪問令牌,看看是否有一個有效的:

NSLog(@"AccessToken:%@ ",FBSession.activeSession.accessTokenData.accessToken); 

你需要通過Facebook登錄到您的應用程序,並需要有publish_actions許可批准之前,你可以做的POST請求任何形式。 獲得訪問令牌後,要快速驗證其是否有效並具有適當的權限,請使用access token debugger