1

I am trying to access update profile api of twitter. But its giving error.

let conn = WebserviceConnectionManager(serviceTokenId: "Twitter profile")

        let url = NSURL(string: "https://api.twitter.com/1.1/account/update_profile.json")
        let request = NSMutableURLRequest(URL: url!)
        request.HTTPMethod = "POST"

        let oAuthToken = FHSTwitterEngine.sharedEngine().accessToken.key
        let oAuthTokenSecret = FHSTwitterEngine.sharedEngine().accessToken.secret

        request.addValue(oAuthToken, forHTTPHeaderField:"oauth_token")
        request.addValue(oAuthTokenSecret, forHTTPHeaderField:"oauth_token_secret")

        conn.delegate = self
        conn.startConnection(request)

Callback method gives me following error:

errors =     (
            {
        code = 215;
        message = "Bad Authentication data.";
    }
);

Any help would be highly appreciated.

TechBee
  • 1,897
  • 4
  • 22
  • 46

1 Answers1

0

Since Twitter's API 1.1 does not allow access without authentication, because you have to use access tokens and secret keys; all requests must be made with a server-side script. follow steps here and you will fixed your problem.

Ahmed Abdallah
  • 2,338
  • 1
  • 19
  • 30
  • I am doing the authentication using FHSTwitterEngine. After successful login, I am calling the rest API. – TechBee May 12 '16 at 13:19
  • @TechBee check it please http://stackoverflow.com/questions/17081012/how-to-get-user-details-using-twitter-api-v1-1-twitter-error-215 – Ahmed Abdallah May 12 '16 at 14:19