0

I am trying to get tweets from Twitter to my Sinatra application. For that I am using REST API v1.0. It shows some functionality error so I am trying to migrate from v1.0 to v1.1. As a part of migration I am using the following code to get response:

response = http.request(Net::HTTP::Get.new("https://api.twitter.com/1.1/search/tweets.json?q=#{search_term}"))

but it shows some error like

{"errors":[{"message":"Bad Authentication data","code":215}]}

How can I fix this?

P J S
  • 170
  • 2
  • 16
  • 1
    The issue is that your authentication (OAuth?) isn't set up correctly. I can't help you further than that, but I suggest looking at other people's examples of setting up OAuth to pass through with your request. – Jimbo Jun 12 '13 at 08:51
  • 1
    http://stackoverflow.com/questions/12684765/twitter-api-returns-error-215-bad-authentication-data?rq=1 – Pramod Jun 12 '13 at 16:25
  • Thanks Jimbo. I configured Twitter configurations and added some new syntax for getting search item results like this. Twitter.configure do |config| config.consumer_key = 'mykey' config.consumer_secret = 'my secret' config.oauth_token = 'oauth_token' config.oauth_token_secret = 'oauth_secret' end tweets = Twitter.search("#{search_term}").results Now it is working fine. – P J S Jun 13 '13 at 03:27
  • @PJS Can u place the code of url how to add consumer key and consumer secret parameters?? – Avadhani Y Sep 12 '13 at 05:29
  • @AvadhaniY here is the code Twitter.configure do |config| config.consumer_key = 'your_consumer_key' config.consumer_secret = 'your_consumer_secret' config.oauth_token = 'your_oauth_token' config.oauth_token_secret = 'your_oauth_secret' end Thanks – P J S Sep 12 '13 at 06:20

0 Answers0