-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
85 additions
and
14 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 |
---|---|---|
|
@@ -3,7 +3,4 @@ | |
*.db-shm | ||
*.db-wal | ||
|
||
Pi/errorlog.txt | ||
Pi/locationlog.txt | ||
Pi/mimiclog.txt | ||
|
||
Pi/TwitterKeys.xml |
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,7 @@ | ||
<?xml version="1.0" ?> | ||
<TwitterKeys> | ||
<ConsumerKey></ConsumerKey> | ||
<ConsumerSecret></ConsumerSecret> | ||
<AccessToken></AccessToken> | ||
<AccessTokenSecret></AccessTokenSecret> | ||
</TwitterKeys> |
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,44 @@ | ||
import tweepy | ||
import xml.etree.ElementTree as etree | ||
|
||
# Twitter API credentials | ||
consumerKey = '' | ||
consumerSecret = '' | ||
accessToken = '' | ||
accessTokenSecret = '' | ||
|
||
# Retrieving key and tokens used for 0Auth | ||
tree = etree.parse('../TwitterKeys.xml') | ||
root = tree.getroot() | ||
for child in root: | ||
if child.tag == 'ConsumerKey' and child.text is not None: | ||
consumerKey = child.text | ||
print("Consumer Key: " + consumerKey) | ||
elif child.tag == 'ConsumerSecret' and child.text is not None: | ||
consumerSecret = child.text | ||
print("Consumer Secret: " + consumerSecret) | ||
elif child.tag == 'AccessToken': | ||
accessToken = child.text | ||
print("Access Token: " + accessToken) | ||
elif child.tag == 'AccessTokenSecret': | ||
accessTokenSecret = child.text | ||
print("Access Token Secret: " + accessTokenSecret) | ||
else: | ||
print("Warning: Unknown or Empty element: " + child.tag) | ||
print(" Twitter fetching may not work.") | ||
|
||
#OAuth process, using the keys and tokens | ||
auth = tweepy.OAuthHandler(consumerKey, consumerSecret) | ||
auth.set_access_token(accessToken, accessTokenSecret) | ||
|
||
# Creation of the actual interface, using authentication | ||
api = tweepy.API(auth) | ||
|
||
# Testing your account | ||
api.update_status('Hello Python Central!') | ||
print("Check your twitter page for the status \"Hello Python Central!\"") | ||
|
||
# Testing retrieve from mimic twitter. | ||
# comment out line 38 before uncommenting the following. | ||
#stuff = api.user_timeline(screen_name = 'iss_mimic', count = 1, include_rts = True, tweet_mode = 'extended') | ||
#print(stuff) |