meo*_*eow 1 ios twitter-fabric
我正在尝试使用适用于iOS的TwitterKit API提取列表成员.据我了解,这样做将使我能够"客户验证",绕过我个人消费者和消费者密钥的需要.
下面的代码尝试使用此REST端点获取列表的成员
let client = TWTRAPIClient()
let endpoint = "https://api.twitter.com/1.1/lists/members.json"
let params = ["owner_screen_name" : "palafo", "slug" : "breakingnews"]
var clientError : NSError?
let request = client.URLRequestWithMethod("GET", URL: endpoint, parameters: params, error: &clientError)
client.sendTwitterRequest(request) { (response, data, connectionError) -> Void in
if connectionError != nil {
print("Error: \(connectionError)")
}
do {
let json = try NSJSONSerialization.JSONObjectWithData(data!, options: [])
print("json: \(json)")
} catch let jsonError as NSError {
print("json error: \(jsonError.localizedDescription)")
}
}
Run Code Online (Sandbox Code Playgroud)
运行,这给了我这个错误:
Error Domain=TwitterAPIErrorDomain Code=220 "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/lists/members.json?owner_screen_name=palafo&slug=breakingnews, NSLocalizedDescription=Request failed: forbidden (403)})
Run Code Online (Sandbox Code Playgroud)
如果我endpoint改为使用其他REST端点获取该列表中的状态,则会得到正确的JSON响应.
let endpoint = "https://api.twitter.com/1.1/lists/statuses.json"
Run Code Online (Sandbox Code Playgroud)
这是否意味着Fabric的访客身份验证不允许我获取列表成员?
我通过使用clientWithUserId而不是仅使用init初始化来解决我的问题.
NSString *userID = [Twitter sharedInstance].sessionStore.session.userID;
TWTRAPIClient *client = [[TWTRAPIClient alloc] initWithUserID:userID];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1525 次 |
| 最近记录: |