Created
January 29, 2015 16:52
-
-
Save szolotykh/e4924159d79ddbaa12c6 to your computer and use it in GitHub Desktop.
Script post on twitter message and image with tweepy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tweepy | |
import os | |
# Consumer keys and access tokens, used for OAuth | |
consumer_key = '' | |
consumer_secret = '' | |
access_token = '' | |
access_token_secret = '' | |
# 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) | |
# Creates the user object. The me() method returns the user whose authentication keys were used. | |
user = api.me() | |
print('Name: ' + user.name) | |
print('Location: ' + user.location) | |
print('Friends: ' + str(user.friends_count)) | |
# Sample method, used to update a status | |
# api.update_status('Hello Form RBI Lab!') | |
# load image | |
imagePath = "img.jpg" | |
status = "Hi! From Python script=)" | |
# Send the tweet. | |
api.update_with_media(imagePath, status) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment