Swift 3 - 上传视频文件到 facebook
Swift 3 - Upload video file to facebook
如何从本地目录将视频文件分享到 facebook。
let dataTs: Data?
我尝试使用其他解决方案,但它们不起作用
var videoData: Data
do {
videoData = ServerManager.sharedManager.dataTs
print(videoData)
var strDesc : String
strDesc = "test Description"
let videoObject: [String : Any] = ["title": "Millions Poet", "description": strDesc]
let uploadRequest: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me/videos", parameters: videoObject, httpMethod: "POST")
uploadRequest.start(completionHandler: {(connection: FBSDKGraphRequestConnection, result: AnyObject, error: NSError) -> Void in
if error == error {
NSLog("Error")
} else {
NSLog("Success")
}
} as! FBSDKGraphRequestHandler)
} catch {
print(error)
}
Swift3码
// Initialize like usual
CRCloudRail.setAppKey("[YourLicenseKey]")
// let social = Twitter(clientID: "[clientID]", clientSecret: "[clientSecret]")
// let social = FacebookPage(pageName: "[pageName]", clientID: "[clientID]", clientSecret: "[clientSecret]")
let social = Facebook(clientID: "[clientID]", clientSecret: "[clientSecret]")
// Get the parameters
let message = "I love CloudRail!!"
let inputStream = // stream to video content
let mime = "video/mp4"
// Make the request
social.postVideo(message: message, video: inputStream, size: 3242456, mimeType: mime)
如何从本地目录将视频文件分享到 facebook。
let dataTs: Data?
我尝试使用其他解决方案,但它们不起作用
var videoData: Data
do {
videoData = ServerManager.sharedManager.dataTs
print(videoData)
var strDesc : String
strDesc = "test Description"
let videoObject: [String : Any] = ["title": "Millions Poet", "description": strDesc]
let uploadRequest: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me/videos", parameters: videoObject, httpMethod: "POST")
uploadRequest.start(completionHandler: {(connection: FBSDKGraphRequestConnection, result: AnyObject, error: NSError) -> Void in
if error == error {
NSLog("Error")
} else {
NSLog("Success")
}
} as! FBSDKGraphRequestHandler)
} catch {
print(error)
}
Swift3码
// Initialize like usual
CRCloudRail.setAppKey("[YourLicenseKey]")
// let social = Twitter(clientID: "[clientID]", clientSecret: "[clientSecret]")
// let social = FacebookPage(pageName: "[pageName]", clientID: "[clientID]", clientSecret: "[clientSecret]")
let social = Facebook(clientID: "[clientID]", clientSecret: "[clientSecret]")
// Get the parameters
let message = "I love CloudRail!!"
let inputStream = // stream to video content
let mime = "video/mp4"
// Make the request
social.postVideo(message: message, video: inputStream, size: 3242456, mimeType: mime)