gpt4 book ai didi

iOS TWTRComposer 请求失败 : unauthorized (401)

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:11:49 29 4
gpt4 key购买 nike

使用以下代码和我尝试过的许多其他变体,我总是会遇到未经授权的错误。我正在使用 TwitterKit 3.0 和 CocoaPods。我已经设置了 plist,配置了我的 Twitter 应用程序,并且编写了如下代码:

// In didFinishLaunchingWithOptions
Twitter.sharedInstance().start(withConsumerKey:"XX", consumerSecret:"YYY")

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool
{
return Twitter.sharedInstance().application(app, open: url, options: options)
}

// In response to a click
Twitter.sharedInstance().logIn { session, error in
if session != nil { // Log in succeeded
let composer = TWTRComposer()

composer.setText(tweetText)

composer.show(from: self.navigationController!) { result in
if (result == .done) {
print("Successfully composed Tweet")
} else {
print("Cancelled composing")
}
}
}
}

"Did encounter error sending Tweet: Error Domain=TWTRNetworkingErrorDomain Code=-1011 "Request failed: unauthorized (401)" UserInfo={NSLocalizedFailureReason=, TWTRNetworkingStatusCode=401, NSErrorFailingURLKey=https://api.twitter.com/1.1/statuses/update.json, NSLocalizedDescription=Request failed: unauthorized (401)"

最佳答案

如果在按照 Twitter 的设置说明进行操作后仍无法正常工作,请尝试重新生成消费者 key 。这解决了我的问题。

关于iOS TWTRComposer 请求失败 : unauthorized (401),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44491349/

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