2012-12-10 32 views
0

在我的應用程序中,我試圖上傳使用FbConnect在Facebook牆上的視頻我的代碼看起來oky但我不知道爲什麼我的視頻沒有上傳如果我使用相同的代碼方法上傳圖像它成功上傳圖像在臉書上。這裏是我的代碼,我使用的圖片上傳如何使用FBConncet在Facebook上上傳視頻?

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"2" ofType:@"png"]; 
NSURL *url = [NSURL URLWithString:path]; 
NSData *data = [NSData dataWithContentsOfFile:filePath]; 
UIImage *img = [[UIImage alloc] initWithData:data]; 
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
          img, @"Picture", 
          nil]; 
[_facebook requestWithGraphPath:@"me/photos" 
        andParams:params 
        andHttpMethod:@"POST" 
        andDelegate:self]; 
[img release]; 

和用於視頻我試圖此代碼,以便爲

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"myVideo" ofType:@"mp4"]; 
NSURL *url = [NSURL URLWithString:filePath]; 
NSData *videoData = [NSData dataWithContentsOfURL:url]; 
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
           videoData, @"video.mp4", 
           @"video/quicktime", @"contentType", 
           @"Video Test Title", @"title", 
           @"Video Test Description", @"description", 
           nil]; 
[_facebook requestWithGraphPath:@"me/videos" 
        andParams:params 
       andHttpMethod:@"POST" 
        andDelegate:self]; 

上面的代碼給我沒有錯誤,但它retun在標籤的一些文字信息(操作無法完成)。這不是圖像上傳的情況。所以可以引導我如何解決它。由於

回答

3
http://stackoverflow.com/questions/10509984/how-to-upload-mp4-video-on-facebook-using-graph-api-in-objective-c 

http://%5B1%5D:%20https://github.com/reallylongaddress/iPhone-Facebook-Graph-API 

http://stackoverflow.com/questions/12861615/upload-video-to-facebook-using-facebook-new-sdk-on-ios-6-0 
+0

Sahil告訴我一件事,我可以修復現有的代碼,因爲當我用它的圖像相同的代碼作品。 – NSCool

+0

@lena閱讀oAuth2Test fb完整教程.. – Bajaj

+0

謝謝讓我檢查它 – NSCool

5

嘗試這些行:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"myVideo" ofType:@"mp4"]; 
     NSData *videoData = [NSData dataWithContentsOfFile:filePath]; 
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
            videoData, @"video.mp4", 
            @"video/quicktime", @"contentType", 
            @"Video Test Title", @"title", 
            @"Video Test Description", @"description", 
            nil]; 
    [_facebook requestWithGraphPath:@"me/videos" 
         andParams:params 
        andHttpMethod:@"POST" 
         andDelegate:self]; 

希望這有助於爲you.its工作me.Now罰款加上這些行。

+0

代碼就給我警告警告:不兼容的Objective-C型 '結構的NSString *',預期 '結構NSURL *' 傳遞的參數1時的 'dataWithContentsOfURL:' 從不同的Objective-C型 – NSCool

+1

的NSData *可視數據= [NSData dataWithContentsOffile:filePath];現在添加這行,它爲你工作。 – Vishal