使用 Swifter 框架/库发布带有照片的推文



我正在使用 Swifter 库尝试发布带有照片的推文,但每次尝试时,我都会收到错误"操作无法完成。(SwifteriOS.SwifterError error 1.(">

我的代码看起来像

var tweetMedia: [String: Any]? //I then set tweetMedia to a UIImageView from the UIImagePickerControllerOriginalImage let picForTwitterApi = tweetMedia![UIImagePickerControllerOriginalImage] as! UIImage let image = UIImagePNGRepresentation(picForTwitterApi) as Data? self.swifter?.postTweet(status: tweetText, media: image!, inReplyToStatusID: nil, coordinate: nil, placeID: nil, displayCoordinates: nil, trimUser: false, tweetMode: TweetMode.default, success: { json in self.alert(title: "Tweet PHOTO sent", message: "👍🏾") }, failure: failureHandler)

但它不起作用,我什至尝试过

self.swifter?.postMedia(image!, additionalOwners: nil, success: { json in print(json)

相反,仍然没有成功。当我发布一条普通的香草推文时,例如 self.swifter?.postTweet(status: tweetText, inReplyToStatusID: nil, trimUser: false, tweetMode: TweetMode.default, success: { json in print(json).....

一切正常,只有当我尝试发布照片时,我才遇到问题。请帮忙。提前致谢

我找到了解决方案。图片必须很小。文档建议甚至小于 5mb。我使用的图像只有100KB,它有效。如果我想发布更大的图像/视频(即使只是一张图片(,您必须使用分块媒体发布功能

最新更新