簡體   English   中英

請求失敗:禁止使用(403)Fabric twitterkit

[英]Request failed: forbidden (403) for fabric twitterkit

我正在嘗試使用適用於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)")
   }
}

運行,給我這個錯誤:

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)})

如果將endpoint更改為使用其他REST端點獲取該列表中的狀態, 則會得到正確的JSON響應。

let endpoint = "https://api.twitter.com/1.1/lists/statuses.json"

這是否意味着Fabric的來賓身份驗證不允許我獲取列表的成員?

我通過使用clientWithUserId解決了我的問題,而不是僅使用init進行初始化。

NSString *userID = [Twitter sharedInstance].sessionStore.session.userID;
TWTRAPIClient *client = [[TWTRAPIClient alloc] initWithUserID:userID];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM