Twitter API error

ios
fabric
oauth
twitterkit

#1

Hi,

I need to destroy a friend (unfollow) so this is my code:

        let client = TWTRAPIClient()
        var clientError : NSError?
        
        let statusesShowEndpoint = "https://api.twitter.com/1.1/friendships/destroy.json"
        
        let params = ["user_id":"1401881"]
        
        let request = client.URLRequestWithMethod("DELETE", URL: statusesShowEndpoint, parameters: params, error: &clientError)
        
        client.sendTwitterRequest(request) { (response, data, connectionError) -> Void in
            
            if connectionError != nil {
                print("Error: \(connectionError)")
            }
            
            guard let myData = data else {
                
                print("error nil")
                return
            }
            
            let json = JSON(data: myData)
            print(json)
        }

I got this error:

"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/friendships/destroy.json?user_id

Is this related to API keys? I tried to change them with read/write but still not working!
Any suggestions?

Thanks.


#2

If you’ve changed read only to read + write - try generating your keys again - maybe that could be it?


#3

@IgorBrigadir Thanks for your reply. I regenerated my keys but still I’m getting the same error. Do you think this error is related to oauth?