From 5fa5352662d9787017cc5237d2b3e5669b4e701a Mon Sep 17 00:00:00 2001 From: KellyKiiru Date: Sun, 13 Aug 2023 14:34:15 +0300 Subject: [PATCH 1/5] add virtual environments and secrets file to .gitignore --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 7c7cedc..de1e6e9 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,10 @@ build-iPhoneSimulator/ # Used by RuboCop. Remote config files pulled in from inherit_from directive. # .rubocop-https?--* + +# Virtual environments +venv/ +virtual/ + +# secrets +.env \ No newline at end of file From f3c490e4e07ad65745a72cf4704ab32fffc787a3 Mon Sep 17 00:00:00 2001 From: KellyKiiru Date: Sun, 13 Aug 2023 14:36:19 +0300 Subject: [PATCH 2/5] change consumer_key to api_key; install dotenv; access env variables --- Manage-Tweets/create_tweet.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Manage-Tweets/create_tweet.py b/Manage-Tweets/create_tweet.py index a8efc85..8e00696 100644 --- a/Manage-Tweets/create_tweet.py +++ b/Manage-Tweets/create_tweet.py @@ -1,26 +1,30 @@ from requests_oauthlib import OAuth1Session import os import json +from dotenv import load_dotenv +load_dotenv() # In your terminal please set your environment variables by running the following lines of code. -# export 'CONSUMER_KEY'='' -# export 'CONSUMER_SECRET'='' +# export 'api_key'='' +# export 'api_key_secret'='' -consumer_key = os.environ.get("CONSUMER_KEY") -consumer_secret = os.environ.get("CONSUMER_SECRET") + +api_key = os.environ["API_KEY"] +api_key_secret = os.environ["API_KEY_SECRET"] # Be sure to add replace the text of the with the text you wish to Tweet. You can also add parameters to post polls, quote Tweets, Tweet with reply settings, and Tweet to Super Followers in addition to other features. -payload = {"text": "Hello world!"} +payload = {"text": "This was tweeted from VScode in Python!"} # Get request token request_token_url = "https://api.twitter.com/oauth/request_token?oauth_callback=oob&x_auth_access_type=write" -oauth = OAuth1Session(consumer_key, client_secret=consumer_secret) +oauth = OAuth1Session(api_key +, client_secret=api_key_secret) try: fetch_response = oauth.fetch_request_token(request_token_url) except ValueError: print( - "There may have been an issue with the consumer_key or consumer_secret you entered." + "There may have been an issue with the API_KEY_SECRET or api_key_secret you entered." ) resource_owner_key = fetch_response.get("oauth_token") @@ -36,8 +40,8 @@ # Get the access token access_token_url = "https://api.twitter.com/oauth/access_token" oauth = OAuth1Session( - consumer_key, - client_secret=consumer_secret, + api_key, + client_secret=api_key_secret, resource_owner_key=resource_owner_key, resource_owner_secret=resource_owner_secret, verifier=verifier, @@ -49,8 +53,8 @@ # Make the request oauth = OAuth1Session( - consumer_key, - client_secret=consumer_secret, + api_key, + client_secret=api_key_secret, resource_owner_key=access_token, resource_owner_secret=access_token_secret, ) From e3da936ec06a26cc63263dd229eee9944ea40ded Mon Sep 17 00:00:00 2001 From: KellyKiiru Date: Sun, 13 Aug 2023 14:36:54 +0300 Subject: [PATCH 3/5] add requirements file for python --- requirements.txt | Bin 0 -> 316 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..87a7cd4cceb37e30cc9c798b3fb2531d7c4c5a15 GIT binary patch literal 316 zcmZXP-3o$05QWcm(4#2+1YPwoW`=^bWg6JSSKrK*7sYa5XU@-_eLZV68Z@fY5$rgH zGEgej78IPdR;tyiLU}_!D$!Yi>BO$b_wW>Ro38+wyE+|ER-S9j#CVr8kS3H I1|NU%2Eb1+d;kCd literal 0 HcmV?d00001 From 82941b313a31bf2a37852f0982def72f3400a1f1 Mon Sep 17 00:00:00 2001 From: KellyKiiru Date: Sun, 13 Aug 2023 15:38:51 +0300 Subject: [PATCH 4/5] change consumer key to api key in project readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8da353e..ff9f5c6 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,11 @@ Individual API features have folders where you can find examples of usage in sev In order to run the samples in this repository you will need to set up some environment variables. You can find your credentials and bearer token in the App inside of your Project in the [dashboard of the developer portal](https://developer.twitter.com/en/portal/projects-and-apps). -For OAuth 1.0a samples, you will need to export your consumer key and secret in your terminal. Be sure to replace `` and `` with your own credentials without the `< >`. +For OAuth 1.0a samples, you will need to export your consumer key and secret in your terminal. Be sure to replace `` and `` with your own credentials without the `< >`. ```bash -export CONSUMER_KEY='' -export CONSUMER_SECRET='' +export API_KEY='' +export API_KEY_SECRET='' ``` For samples which use bearer token authentication, you will need to export the bearer token. Be sure to replace `` with your own bearer token without the `< >`. From fb05a2dc04b33334f01f6b6505932e35c6233adb Mon Sep 17 00:00:00 2001 From: kellykiiru Date: Thu, 14 Dec 2023 23:39:35 +0300 Subject: [PATCH 5/5] changes --- Manage-Tweets/create_tweet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Manage-Tweets/create_tweet.py b/Manage-Tweets/create_tweet.py index 8e00696..86e523b 100644 --- a/Manage-Tweets/create_tweet.py +++ b/Manage-Tweets/create_tweet.py @@ -13,7 +13,7 @@ api_key_secret = os.environ["API_KEY_SECRET"] # Be sure to add replace the text of the with the text you wish to Tweet. You can also add parameters to post polls, quote Tweets, Tweet with reply settings, and Tweet to Super Followers in addition to other features. -payload = {"text": "This was tweeted from VScode in Python!"} +payload = {"text": "You guys didn't tell me that IELTS are that expensive. Damn!"} # Get request token request_token_url = "https://api.twitter.com/oauth/request_token?oauth_callback=oob&x_auth_access_type=write"