-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JD: Adjusts procfile and scorer_app.py (underscores in fn names), add…
…s scripts dir.
- Loading branch information
John Demos
committed
Sep 13, 2019
1 parent
8fb3f22
commit 6523671
Showing
5 changed files
with
85 additions
and
7 deletions.
There are no files selected for viewing
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,3 @@ | ||
.env | ||
.DS_Store | ||
.DS_Store? |
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 @@ | ||
web: gunicorn Main:app --log-file=- | ||
web: gunicorn scorer_app:app |
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
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,26 @@ | ||
import json | ||
import os | ||
import sys | ||
|
||
import requests | ||
from requests_oauthlib import OAuth1 | ||
from dotenv import load_dotenv | ||
load_dotenv(verbose=True) # Throws error if it can't find .env file | ||
|
||
# Retrieves and stores credential information from the '.env' file | ||
CONSUMER_KEY = os.getenv("TWITTER_CONSUMER_KEY") | ||
CONSUMER_SECRET = os.getenv("TWITTER_CONSUMER_SECRET") | ||
ACCESS_TOKEN = os.getenv("TWITTER_ACCESS_TOKEN") | ||
TOKEN_SECRET = os.getenv("TWITTER_ACCESS_TOKEN_SECRET") | ||
|
||
# Generate user context auth (OAuth1) | ||
user_context_auth = OAuth1(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, TOKEN_SECRET) | ||
|
||
payload = {'status': 'Fore!'} | ||
|
||
def post_tweet(status): | ||
endpoint = "https://api.twitter.com/1.1/statuses/update.json" | ||
response = requests.post(endpoint, auth=user_context_auth, params=payload) | ||
print(response.status_code, response.text) | ||
|
||
post_tweet(payload) |
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,42 @@ | ||
import json | ||
import os | ||
import sys | ||
|
||
import requests | ||
from requests_oauthlib import OAuth1 | ||
from dotenv import load_dotenv | ||
load_dotenv(verbose=True) # Throws error if it can't find .env file | ||
|
||
# Retrieves and stores credential information from the '.env' file | ||
CONSUMER_KEY = os.getenv("TWITTER_CONSUMER_KEY") | ||
CONSUMER_SECRET = os.getenv("TWITTER_CONSUMER_SECRET") | ||
ACCESS_TOKEN = os.getenv("TWITTER_ACCESS_TOKEN") | ||
TOKEN_SECRET = os.getenv("TWITTER_ACCESS_TOKEN_SECRET") | ||
|
||
# Generate user context auth (OAuth1) | ||
user_context_auth = OAuth1(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, TOKEN_SECRET) | ||
|
||
# Assign the resource and webhook urls | ||
resource_url = "https://api.twitter.com/1.1/account_activity/all/dev/webhooks.json" | ||
|
||
url_dict = {'url': 'https://hacker-scorer.herokuapp.com/webhook'} | ||
|
||
headers = {"Content-Type": "application/x-www-form-urlencoded"} | ||
|
||
|
||
response = requests.post(resource_url, auth=user_context_auth, headers=headers, params=url_dict) | ||
print(response.status_code, response.text) | ||
|
||
# def register_webhook(webhook_url): | ||
# # Generate user context auth (OAuth1) | ||
# user_context_auth = OAuth1(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, TOKEN_SECRET) | ||
# try: | ||
# response = requests.post(resource_url, auth=user_context_auth, params=webhook_url) | ||
# except requests.exceptions.RequestException as e: | ||
# print(e) | ||
# sys.exit(120) | ||
|
||
# print(response.status_code, response.text) | ||
|
||
# Call the register_webhook function | ||
# register_webhook(my_webhook_url) |