我正在尝试将视频文件从iOS上传到Facebook的GraphAPI。 可悲的是,它没有按预期工作。虽然This表示应该支持我的本地.mov,但我收到以下错误:
Error: Error Domain=com.facebook.sdk.core Code=8 "The operation couldn’t be completed. (com.facebook.sdk.core error 8.)" UserInfo=0x161a2f30 {com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=352, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={
body = {
error = {
code = 352;
message = "(#352) Sorry, the video file you selected is in a format that we don't support.";
type = OAuthException;
};
};
code = 400;
},
com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=400,
com.facebook.sdk:FBSDKErrorDeveloperMessageKey=(#352) Sorry, the video file you selected is in a format that we don't support., com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=0}
我的代码如下:
//Outlet 4 picking movie file from PhotoLibrary
@IBAction func shareVideo(sender: UIButton) {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.PhotoLibrary){
println("Video capture")
imagePicker.delegate = self
imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
imagePicker.allowsEditing = false
imagePicker.mediaTypes = [kUTTypeMovie]
self.presentViewController(imagePicker, animated: true, completion: nil)
}
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
println(info)
//Stoping the ImagePickerView
imagePicker.dismissViewControllerAnimated(true, completion: nil)
var videoDatei : NSData = NSData(contentsOfURL: info[UIImagePickerControllerMediaURL] as! NSURL)!
var params : NSDictionary = ["source" : videoDatei ]
var token = FBSDKAccessToken.currentAccessToken().tokenString
var videoRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me/videos", parameters: params as [NSObject : AnyObject], tokenString: token, version: nil, HTTPMethod: "POST")
videoRequest.startWithCompletionHandler({ (connection, result, error) -> Void in
if ((error) != nil)
{
// Process error
println("Error: \(error)")
}
else
{
println(result)
}
})
}
除了之外,FacebookSDK文档没有提供videoupload的任何示例代码
NSDictionary *params = @{
@"source": @"{video-data}",
};
并发送请求,{video-data}除了“multipart / form-data”之外没有任何信息,我还不完全理解。
的信息: iOS 8.3 迅速 FacebookSDK v.4.1.0 FBSDK GraphAPI v.2.3
感谢您的所有时间, ROLF