TwitterKit 共享停止工作

TwitterKit sharing stopped working

从我的应用程序将照片上传到用户的 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 会话的方式:

    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,它仍然给我 "Could not authenticate you" 错误。

他们发布了包含 public 上传功能的 TwitterKit 2.0 版。