0

I am trying to fetch tweets from the search api and not able to proceed as I am not sure what the problem is.

Code.

import httplib2
import oauth2 as oauth
import time
import certifi

consumer_key,consumer_secret,access_key,access_secret = "ck","cd","ak","as"
token = oauth.Token(key=access_key,secret=access_secret)
consumer = oauth.Consumer(key=consumer_key,secret=consumer_secret)
url = "https://api.twitter.com/1.1/search/tweets.json?q=Obama&count=10&result_type=recent"
req = oauth.Request(method="GET",url=url)
signature_method = oauth.SignatureMethod_HMAC_SHA1()
req.sign_request(signature_method,consumer,token)
h = httplib2.Http(disable_ssl_certificate_validation=True)
resp, content = h.request(url,method="GET")

The resp and content are given below.

resp

'status': '401'

content

\r\nAccess Denied\r\n\r\n\r\n\r\n
\r\n\r\n

\r\n\r\n\r\n\r\nAccess Denied (authentication_failed)\r\n
\r\n
\r\n\r\n\r\n\r\n\r\nYour credentials could not be authenticated: "Credentials are missing.". You will not be permitted access until your credentials can be verified.\r\n\r\n\r\n\r\n\r\nThis is typically caused by an incorrect username and/or password, but could also be caused by network problems.\r\n\r\n\r\n\r\n\r\n
\r\nFor assistance, contact your network support team.\r\n\r\n\r\n\r\n
\r\n\r\n\r\n

But I know the authentications are right as I am using the same auth in home pc without sitting behind firewall. Any suggestion to get the result will be apreciated.

LonelySoul
  • 1,212
  • 5
  • 18
  • 45

0 Answers0