Error code 403 when using guest authentication with TwitterKit iOS for getting user timeline

徘徊边缘 提交于 2019-12-11 02:25:26

问题


I am using Fabric's twitter kit for getting a username's tweets in my iOS application by making a request to the REST API endpoint "https://api.twitter.com/1.1/statuses/user_timeline.json"

I am have correctly set up my "consumer key" and "consumer secret key" as provided by the Fabric app in my AppDelegate and info.plist , but I repeatedly get the following error message -

Error: Optional(Error Domain=TwitterAPIErrorDomain Code=200 "Request failed: forbidden (403)" UserInfo={NSErrorFailingURLKey=https://api.twitter.com/1.1/guest/activate.json, NSLocalizedDescription=Request failed: forbidden (403), NSLocalizedFailureReason=Twitter API error : Forbidden. (code 200)})

My code is as under follows -

        Twitter.sharedInstance().startWithConsumerKey(TWITTER_CONSUMER_KEY, consumerSecret: TWITTER_CONSUMER_KEY_SECRET)
        Fabric.with([Twitter.sharedInstance()])

        let userId = Twitter.sharedInstance().sessionStore.session()?.userID
        let client = TWTRAPIClient.init(userID: userId)
        let params = ["screen_name": twitterUsername, "count" : "10"]
        var clientError : NSError?

        let request = client.URLRequestWithMethod("GET", URL: TWITTER_TIMELINE_ENDPOINT, parameters: params, error: &clientError)

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

I am on the most recent version of TwitterKit(>2.0)

How can I go about resolving this ?

Thanks!


回答1:


Add key in exception domains as shown in info.plist. Following fixed bug for me.



来源:https://stackoverflow.com/questions/36348516/error-code-403-when-using-guest-authentication-with-twitterkit-ios-for-getting-u

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!