gpt4 book ai didi

ios - 错误响应 TwitterKit

转载 作者:行者123 更新时间:2023-11-28 12:17:30 25 4
gpt4 key购买 nike

我有一个请愿 url 请求,但问题是响应数据为 nil ,对于其他 url 请求,请愿成功但没有这个功能!任何想法 ?

let client = TWTRAPIClient()
let statusesShowEndpoint = "https://api.twitter.com/1.1/statuses/home_timeline.json"
//let params = ["id": "20"]
var clientError : NSError?

let request = client.urlRequest(withMethod: "GET", url: statusesShowEndpoint, parameters: nil, error: &clientError)


client.sendTwitterRequest(request) { (response, data, connectionError) -> Void in
if connectionError != nil {
print("Error: \(connectionError)")
}

do {
let json = try JSONSerialization.jsonObject(with: data!, options: [])
print("json: \(json)")
} catch let jsonError as NSError {
print("json error: \(jsonError.localizedDescription)")
}
}

控制台出现错误

"Request failed: forbidden (403)" UserInfo={NSLocalizedFailureReason=Twitter API error : Your credentials do not allow access to this resource. (code 220), TWTRNetworkingStatusCode=403, NSErrorFailingURLKey=https://api.twitter.com/1.1/statuses/home_timeline.json, 

但是对于这个请求是独占的,其他请求api不会出现这个错误。

最佳答案

尝试使用这段代码,它对我有用:

var userID: String = Twitter.sharedInstance().sessionStore.session.userID
var client = TWTRAPIClient(userID: userID)

关于ios - 错误响应 TwitterKit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45979401/

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