import tweepy import webbrowser # Consumer keys and access tokens, used for OAuth consumer_key = 'LshCDe5lj2JhdWyWp29DUspHF' consumer_secret = 'EfOJNIpTAQCzZiKVHaRZc6mwg1TvqAzRKYGtSFQw2O8iHg6sLW' # OAuth process, using the APP's consumer key and secret auth = tweepy.OAuthHandler(consumer_key, consumer_secret) #Open web browser to Twitter auth page webbrowser.open(auth.get_authorization_url()) #Prompt user to enter verification pin from Twitter (web apps can automatically gather this) pin = raw_input('Verification pin number from twitter.com: ').strip() #Authenticate user using provided pin token = auth.get_access_token(verifier=pin) #Set token variables just because access_token = token.key access_token_secret = token.secret #Set user access token auth.set_access_token(access_token, access_token_secret) # Creation of the actual interface, using authentication api = tweepy.API(auth) #Define function that will post tweet def post_tweet(tweet): api.update_status(tweet) #Execute function that posts tweet (commented out) #post_tweet("This is a test tweet")
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question