gpt4 book ai didi

ios - TwitterKit 共享停止工作

转载 作者:可可西里 更新时间:2023-11-01 06:13:57 24 4
gpt4 key购买 nike

将照片从我的应用程序上传到用户的 Twitter 帐户工作正常,但突然间出现此错误:

Error Domain=TwitterAPIErrorDomain Code=32 "Request failed: unauthorized (401)" UserInfo={NSErrorFailingURLKey=https://upload.twitter.com/1.1/media/upload.json, NSLocalizedDescription=Request failed: unauthorized (401), NSLocalizedFailureReason=Twitter API error : Could not authenticate you. (code 32)}

这是我开始 Twitter session 的方式:

    Twitter.sharedInstance().logInWithCompletion({ (session, error) -> Void in
})

下面是我将媒体上传到 Twitter 的方式,错误来自 sendtwitterRequest 方法:

    let store = Twitter.sharedInstance().sessionStore

if let userid = store.session()?.userID {

let client = TWTRAPIClient(userID: userid) //we have this from logInWithCompletion() in the previousVC

let imageData = UIImagePNGRepresentation(self.cardView.takeSnapshot())
let uploadParams = ["media" : imageData!.base64EncodedStringWithOptions(NSDataBase64EncodingOptions.Encoding64CharacterLineLength)]
//TODO: Handle error properly (do / catch?)
let uploadRequest = client.URLRequestWithMethod(kTwitterPOSTmethod, URL: kTwitterUploadURL, parameters: uploadParams, error: nil)

//First we upload the image via a request
client.sendTwitterRequest(uploadRequest, completion: { (response, uploadResultData, error) -> Void in

..使用 sendTwitterRequest 方法返回上述错误。

有什么想法吗?我更新了 TwitterKit SDK,它仍然给我“无法验证你”的错误。

最佳答案

他们发布了包含公共(public)上传功能的 TwitterKit 2.0 版本。

关于ios - TwitterKit 共享停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34733510/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com