I was was trying to send a request for retrieving a list of the top 10 trending topics by using the GET trends/places
API provided by Twitter at https://dev.twitter.com/docs/api/1.1/get/trends/place. Here's the code for the same in Python:
import twitter
CONSUMER_KEY = ' XXXXXXXXXX'
CONSUMER_SECRET ='XXXXXXXXXXXX'
OAUTH_TOKEN = ' XXXXXXXXX'
OAUTH_TOKEN_SECRET = ' XXXXXXX'
auth = twitter.oauth.OAuth(OAUTH_TOKEN, OAUTH_TOKEN_SECRET,
CONSUMER_KEY, CONSUMER_SECRET)
twitter_api = twitter.Twitter(auth=auth)
WORLD_WOE_ID = 1
world_trends = twitter_api.trends.place(_id=WORLD_WOE_ID)
print world_trends
When I only try to print 'twitter_api', I get the following as the output:
<twitter.api.Twitter object at 0x39d9b50>
which means that I have successfully used OAuth credentials to gain authorization to query Twitter's API. Now, after I run the above code, here's the error that I get:
TwitterHTTPError: Twitter sent status 400 for URL: 1.1/trends/place.json using parameters: (id=1&oauth_consumer_key=%201FqhG77x7XaVjx6a1lnm2ip8G&oauth_nonce=3628940350753944768&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1399534257&oauth_token=%20337142662-QWaMBk6MCe5vM6to5tw3AR3cHChYc0e0yUnEB7lh&oauth_version=1.0&oauth_signature=%2BD0ZzXV8cMuc5S%2B9UKRJ85xF1wY%3D)
details: {"errors":[{"message":"Bad Authentication data","code":215}]}
From the error message, I figured that the error has got something to do with bad syntax(since I get an HTTP 400 error message). Also, when I try to use the example URL mentioned on https://dev.twitter.com/docs/api/1.1/get/trends/place, I still get the following error: {"errors":[{"message":"Bad Authentication data","code":215}]}
What seems to be the problem with the code? I've tried finding the root cause of the error, but have failed to find any significant lead.