Last active
April 20, 2018 13:07
-
-
Save jerinisready/af51aa2bdcfbf760031587ed71cef7d1 to your computer and use it in GitHub Desktop.
Fun @ GDGCochin #DevFest17
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
class A: | |
KEY = 'u5NeFqa------------tZ2UM' | |
SECRET = 'WgWtW3tL_--------------------------IlKD5GTHCfTjrLBsrC' | |
TOKEN = '1495931731-r----------------------------kjpfcMAjXxk' | |
TOKEN_SECRET = 'Im24KQ------------------------------fMJyK' | |
api_keys = A() | |
from requests_oauthlib import OAuth1Session | |
import json | |
twitter = OAuth1Session(api_keys.KEY, | |
client_secret=api_keys.SECRET, | |
resource_owner_key=api_keys.TOKEN, | |
resource_owner_secret=api_keys.TOKEN_SECRET) | |
hashtag = "#GDGCochin, #gdgcochin, #DevFest17, #devfest17, @gdgcochin" | |
r = twitter.post( 'https://stream.twitter.com/1.1/statuses/filter.json', data={ 'track': hashtag }, stream=True ) | |
for line in r.iter_lines(): | |
if line: | |
j = json.loads(line.decode('utf-8')) | |
print('\n') | |
print(j['user']['name'], " ---- @%s" % j['user']['screen_name']) | |
print(j['text']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment