3

Last year, I was using a Python script to update my Twitter status, but since Twitter now requires SSL verification the script fails with the following:

Tweepy.error.TweepError: [{'message': 'SSL is required', 'code': 92}]

The script is extremely simple and is below.

# Consumer keys and access tokens, used for OAuth  
consumer_key = 'type in your consumer key here'  
consumer_secret = 'type in your consumer secret here'  
access_token = 'type in your access token here'  
access_token_secret = 'type in your access token secret here'  

# OAuth process, using the keys and tokens  
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)  
auth.set_access_token(access_token, access_token_secret)  

# Creation of the actual interface, using authentication  
api = tweepy.API(auth)  

if len(sys.argv) >= 2:  
    tweet_text = sys.argv[1]  

else:  
    tweet_text = "Still messing about with tweepy and twitter API. :)"  

if len(tweet_text) <= 140:  
    api.update_status(tweet_text)  
else:  
    print "tweet not sent. Too long. 140 chars Max."

Any assistance is appreciated. Thanks.

user3430883
  • 31
  • 1
  • 2
  • I am also having the same problem. I've looked around and found a few hopeful leads, but it still does not work for me and may be my network. But here are some resources you can try: https://dev.twitter.com/overview/api/tls provides .crt files directly (point to them or add to cacert.pem) http://stackoverflow.com/questions/1087227/validate-ssl-certificates-with-python has some discussion on how to set up the cert and issues maybe being with older vers. of python (i'm using 2.7) https://urllib3.readthedocs.io/en/latest/user-guide.html#ssl-py2 using pyopenssl to cert. GL! – Vlox Apr 05 '17 at 11:31

3 Answers3

2

I had a similar problem, but managed to get around it by installing tweepy from the tweepy GitHub repo

git clone https://github.com/tweepy/tweepy.git
python setup.py install

However, most likely, the project you are trying to get to work was written when Twitter REST API was v1. As a result, you might see a new error:

tweepy.error.TweepError: [{'message': 'The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.', 'code': 64}]

SSH This
  • 1,864
  • 4
  • 23
  • 41
0

Try changing

api = tweepy.API(auth)  

to

api = tweepy.API(auth, secure=True)  

That's in version 2.2 of Tweepy.

Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83
mlv
  • 580
  • 4
  • 10
0

Try this.

auth.secure = True

This work for me !!!

abhjt
  • 402
  • 4
  • 11
  • 25