-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: qrshivani <[email protected]>
- Loading branch information
Showing
6 changed files
with
55 additions
and
18 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
import tweepy | ||
def auth(): | ||
import tweepy | ||
|
||
consumer_key = "QS9Vk6mSmKTri97Oz4yNuY3sH" | ||
consumer_secret = "szyiAlz9d0i5PmGEEEkukeyReDYHrFEgaMW2kTkytaqI1W2lH0" | ||
callback= "oob" | ||
consumer_key = "QS9Vk6mSmKTri97Oz4yNuY3sH" | ||
consumer_secret = "szyiAlz9d0i5PmGEEEkukeyReDYHrFEgaMW2kTkytaqI1W2lH0" | ||
callback= "oob" | ||
|
||
oauth1_user_handler = tweepy.OAuth1UserHandler( | ||
consumer_key, consumer_secret, | ||
callback) | ||
oauth1_user_handler = tweepy.OAuth1UserHandler( | ||
consumer_key, consumer_secret, | ||
callback) | ||
|
||
print(oauth1_user_handler.get_authorization_url(access_type='write')) | ||
print("Visit this link to generate 6-digit PIN: ", oauth1_user_handler.get_authorization_url(access_type='write')) | ||
|
||
verifier = input("Input PIN: ") | ||
access_token, access_token_secret = oauth1_user_handler.get_access_token(verifier) | ||
verifier = input("Input PIN: ") | ||
access_token, access_token_secret = oauth1_user_handler.get_access_token(verifier) | ||
|
||
api = tweepy.API(oauth1_user_handler) | ||
with open("credentials.yaml", "w") as f: | ||
f.write("access_token: {}\n".format(access_token)) | ||
f.write("access_token_secret: {}\n".format(access_token_secret)) | ||
|
||
print(api.verify_credentials().screen_name) | ||
api = tweepy.API(oauth1_user_handler) | ||
|
||
print("Signed in as: ", api.verify_credentials().screen_name) | ||
|
||
return api |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
access_token: 1216406244358901760-hhvrs0sFgkaEDVs3HBYQAPCY5HuG7M | ||
access_token_secret: 8PFieUa4Xf4AIxCSrRq6FAamcntWuHGmXvsDZUTrEIPed |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
def new_tweeet(text): | ||
def new_tweeet(text, api): | ||
api.update_status(status = text) | ||
|
||
def del_tweet(id): | ||
def del_tweet(id, api): | ||
api.destroy_status(id) | ||
|
||
|
||
|
||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,32 @@ | ||
import tweepy | ||
import yaml | ||
|
||
from auth import * | ||
from manage import * | ||
|
||
|
||
print("Welcome to Twimanage! This is a simple Twitter management tool. /n") | ||
|
||
# Load credentials and authenticate | ||
try: | ||
api = auth() | ||
print("Authentication successful!") | ||
|
||
except: | ||
print("Authentication failed! Please check your credentials.yaml file.") | ||
exit() | ||
|
||
user_choice = (int(input("1. New Tweet\n2. Delete Tweet(Needs Tweed ID)\n3. Quit\n>>>"))) | ||
if user_choice == 1: | ||
tweet = input("What would you like to tweet? ") | ||
new_tweeet(tweet, api) | ||
print("Tweet sent!") | ||
|
||
elif user_choice == 2: | ||
id = input("What is the ID of the tweet you want to delete? ") | ||
del_tweet(id, api) | ||
print("Tweet deleted!") | ||
|
||
elif user_choice == 3: | ||
print("Goodbye!") | ||
exit() |