4

Is there a way to change your twitter password via the python-twitter API or the twitter API in general? I have looked around but can't seem to find this information...

Stéphane Bruckert
  • 21,706
  • 14
  • 92
  • 130
Dan
  • 2,647
  • 2
  • 27
  • 37

2 Answers2

5

Fortunately not! Passwords are very confidential information which only Twitter itself wants to handle.


Think about a third-party developer suggesting to change your Twitter password:

  • would you trust them and let them see your new password?
  • how could you make sure they are really going to set your new password and not another one?
Stéphane Bruckert
  • 21,706
  • 14
  • 92
  • 130
-1
import urllib.request
import time

def set_password():
password="PASSWORDHERE"

set_password()

def send_to_twitter(msg):
password_manager = urllib.request.HTTPPasswordMgr()
password_manager.add_password("Twitter API",
           "http://twitter.com/statuses", "twitterhandlehere",password)
http_handler = urllib.request.HTTPBasicAuthHandler(password_manager)
page_opener = urllib.request.build_opener(http_handler)
urllib.request.install_opener(page_opener)
params = urllib.parse.urlencode( {'status': msg} )
resp = urllib.request.urlopen("http://twitter.com/statuses/update.json",    params)
resp.read()
  • 7
    While this code may answer the question, it would be better to include some context, explaining how it works and when to use it. Code-only answers are not useful in the long run. – Bono Dec 03 '15 at 20:26