2012-04-06 88 views
0

我可以通過Objective-C使用最新的Graph API成功上傳視頻到Facebook。不過,我還想標記視頻中的某些Facebook用戶。我無法得到這個工作。如何使用Graph API將視頻上傳到Facebook時指定標籤

FB documentation表示有一個「標籤」字段接受包含id和名稱字段的對象數組。但是,如果我嘗試以此格式傳遞JSON字符串,則視頻上傳將失敗,並且不會顯示任何有用的錯誤消息。我是否正確傳遞標籤數據?

以下是失敗的示例代碼。當我從params中刪除@「tags」字段,或將tagStr設置爲空數組,即@「[]」時,代碼成功。

NSString *tagStr = @"[{\"id\":\"<id-removed>\", \"name\":\"<name-removed>\"}]"; 
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
           data, @"video.mov", 
           @"video/quicktime", @"contentType", 
           titleStr, @"title", 
           descStr, @"description", 
           tagStr, @"tags",   // specifying tags fails 
           nil]; 

[facebook requestWithGraphPath:@"me/videos" 
        andParams:params 
       andHttpMethod:@"POST" 
        andDelegate:self]; 

回答

1

你PARAMS解釋應該是這樣,

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
            videoData, @"video.mov", 
            @"video/quicktime", @"contentType", 
            @"Birthday wishes", @"title", 
            @"via Birthday wishes", @"description",facebook.accessToken,@"access_token", 
            nil]; 

視頻被髮布後,您可以能夠標記朋友 - (空)要求:(FBRequest *)要求didLoad:(ID )結果像

[APP.facebook requestWithGraphPath:[NSString stringWithFormat:@"%@/tags/%@?access_token=%@", photoID, [ar_tID objectAtIndex:i], APP.facebook.accessToken]andParams:nilandHttpMethod:@"POST" andDelegate:self];

相關問題