错误响应 TwitterKit
Error response TwitterKit
我有一个请愿书 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)
我有一个请愿书 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)