예제 #1
0
def main():
    api = twitter.api(consumer_key=os.getenv('CONSUMER_KEY'),
                      consumer_secret=os.getenv('CONSUMER_SECRET'),
                      access_token_key=os.getenv('ACCESS_TOKEN_KEY'),
                      access_token_secret=os.getenv('ACCESS_TOKEN_SECRET'))
    msg = raw_input("What do you want to tweet? :")
    tweet(api, msg)
예제 #2
0
    def set_api(self):

        self.api = twitter.api(
            consumer_key=self.twitter_keys['consumer_key'],
            consumer_secret=self.twitter_keys['consumer_secret'],
            access_token_key=self.twitter_keys['access_token_key'],
            access_token_secret=self.twitter_keys['access_token_secret'])
예제 #3
0
def main():
    """ This function will tweet our message """
    api = twitter.api(
        consumer_key=os.getenv('CONSUMER_KEY'),
        consumer_secret=os.getenv('CONSUMER_SECRET'),
        consumer_tocken_secret=os.getenv('CONSUMER_TOCKEN_SECRET'))

    msg = raw_input('what do you want to tweet?:')
    tweet(api, msg)
예제 #4
0
def getLotsOfTweets(searchStr):
    CONSUMER_KEY = "get when you create an app"
    CONSUMER_SECRET = "get"
    ACCESS_TOKEN_KEY = ""
    ACCESS_TOKEN_SECRET = ""
    api = twitter.api(consumer_key=CONSUMER_KEY,
                      consumer_secret=CONSUMER_SECRET,
                      access_token_key=ACCESS_TOKEN_KEY,
                      access_token_secret=ACCESS_TOKEN_SECRET)
    resultPages = []
    for i in range(1, 15):
        print("fetching page %d" % i)
        searchResults = api.GetSearch(searchStr, per_page=100, page=i)
        resultPages.append(searchResults)
        sleep(6)
    return resultPages
def get_tweets():
    api = twitter.api(consumer_key='enter consumer key',
                      consumer_secret='enter consumer secret',
                      access_token_key='enter access token key',
                      access_token_secret='enter access token secret')
    tweets = []
    max_id = None
    for _ in range(100):
        tweets.extend(
            list(
                api.GetUserTimeline(screen_name='doctorsroom',
                                    max_id=max_id,
                                    count=200,
                                    include_rts=False,
                                    exclude_replies=True)))
        max_id = tweets[-1].id
    return [tweet.text for tweet in tweets]
def get_tweets():
    api = twitter.api(
        consumer_key='d3t5F3wXmgiyUkbKNJzQo8CmT',
        consumer_secret='Rklcd7zkTbmOw7X9DS9U5DPwZWjE74HbZhfVsovIblNYgLqgDj',
        access_token_key='2sVJtXU60KhcEFuE3eXznF8Rn',
        access_token_secret='l0ZmId6T4PHqK6VolwVQvVt7Io9F424AAF5puduXLKMvs7IG7q'
    )
    tweets = []
    max_id = None
    for _ in range(100):
        tweets.extend(
            list(
                api.GetUserTimeline(screen_name='doctorsroom',
                                    max_id=max_id,
                                    count=200,
                                    include_rts=False,
                                    exclude_replies=True)))
        max_id = tweets[-1].id
    return [tweet.text for tweet in tweets]
예제 #7
0
import twitter

CONSUMER_KEY = ''
CONSUMER_SECRET = ''
ACCESS_TOKEN_KEY = ''
ACCESS_TOKEN_SECRET = ''

api = twitter.api(consumer_key=CONSUMER_KEY,
                consumer_secret = CONSUMER_SECRET,
                access_token_key = ACCESS_TOKEN_KEY,
                access_token_secret = ACCESS_TOKEN_SECRET
                sleep_on_rate_limit=True)

def postUpdate(reason):

    api.PostUpdate(reason)
    print reason
예제 #8
0
import twitter

twapi = twitter.api()
예제 #9
0
# log files
LATESTFILE = 'bot_latest.txt'
LOGFILE = 'bot_log.txt'

# config file
CONFIG = '/Users/hogstrom/Documents/code/configs/bot2.cfg'
keyDict = {}
with open(CONFIG, 'r') as f:
    for line in f:
        line = line.replace('\n','')
        splt = line.split(' ')
        keyDict[splt[0]] = splt[1]

api = twitter.api(consumer_key=keyDict['consumer_key'],
    consumer_secret=keyDict['consumer_secret'],
    access_token_key=keyDict['access_token_key'],
    access_token_secret=keyDict['access_token_secret'])


from twitter import *

OAUTH_TOKEN=keyDict['access_token_key']
OAUTH_SECRET=keyDict['access_token_secret']
CONSUMER_KEY=keyDict['consumer_key']
CONSUMER_SECRET=keyDict['consumer_secret']

o1 = OAuth(OAUTH_TOKEN, OAUTH_SECRET, CONSUMER_KEY, CONSUMER_SECRET)
t = Twitter(auth=o1)
# see "Authentication" section below for tokens and keys
t = Twitter(
            auth=OAuth(OAUTH_TOKEN, OAUTH_SECRET,
예제 #10
0
# log files
LATESTFILE = 'bot_latest.txt'
LOGFILE = 'bot_log.txt'

# config file
CONFIG = '/Users/hogstrom/Documents/code/configs/bot2.cfg'
keyDict = {}
with open(CONFIG, 'r') as f:
    for line in f:
        line = line.replace('\n', '')
        splt = line.split(' ')
        keyDict[splt[0]] = splt[1]

api = twitter.api(consumer_key=keyDict['consumer_key'],
                  consumer_secret=keyDict['consumer_secret'],
                  access_token_key=keyDict['access_token_key'],
                  access_token_secret=keyDict['access_token_secret'])

from twitter import *

OAUTH_TOKEN = keyDict['access_token_key']
OAUTH_SECRET = keyDict['access_token_secret']
CONSUMER_KEY = keyDict['consumer_key']
CONSUMER_SECRET = keyDict['consumer_secret']

o1 = OAuth(OAUTH_TOKEN, OAUTH_SECRET, CONSUMER_KEY, CONSUMER_SECRET)
t = Twitter(auth=o1)
# see "Authentication" section below for tokens and keys
t = Twitter(
    auth=OAuth(OAUTH_TOKEN, OAUTH_SECRET, CONSUMER_KEY, CONSUMER_SECRET))

def calculate_pr(inb):
    pages = len(inb)
    pr_initial = 1.0 / (pages)
    #pagerank = 0.0
    damping_factor = 0.85
    sum = 0.0
    for i in range(1, len(inbound_link_array)):
        sum += (pr_initial / inbound_link_array[i])
    pagerank = float((1 - damping_factor) / pages) + (damping_factor * sum)
    return pagerank


api = twitter.api(consumer_key=c_key,
                  consumer_secret=c_secret,
                  access_token_key=t_key,
                  access_token_secret=t_secret)
dick = {}
#dick = api.VerifyCredentials()
dick = api.GetFollowers(screen_name='akshaykumar',
                        count=150,
                        skip_status=True,
                        total_count=100)
inbound_link_array = []
inbound_link_array.append(len(dick))
for i in range(len(dick)):
    temp = str(dick[i])
    temp = yaml.load(temp)
    if 'followers_count' in temp:
        inbound_link_array.append(temp['followers_count'])
    else:
예제 #12
0
import webapp2
import os
import json

from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.api import app_identity

from ninja import NinjaLiveData
import twitter

config = json.loads(open('config.json').read())

twapi = twitter.api(config.get('twitter', {}))	
	
class RootHandler(webapp2.RequestHandler):
	
	def get(self):
		
		self.response.headers['Content-Type'] = 'application/json'   
		output = {
			'server': app_identity.get_application_id(),
			'version': os.environ['CURRENT_VERSION_ID']
		} 
		self.response.out.write(json.dumps(output))
	
class TweetHandler(webapp2.RequestHandler):

	def get(self):
		
		tweet_config = config.get("tweet", {})
		ninja_data = NinjaLiveData(config.get("ninja", {}))
예제 #13
0
import sys
import textgenrnn
import twitter
#asks for api stuff
conkey = input("consumer key?")
consec = input("consumer secret?")
accesstok = input("access token?")
accesstoksec = input("access token secret?")
manifest = twitter.api(conkey, consec, accesstok, accesstoksec)
# get tl
cnt = sys.argv[1]
sn = sys.argv[2]
tl = manifest.getUserTimeline(screen_name=sn, count=cnt)
# count and screen names are arguments
tl = get_tweets(api=manifest, screen_name=sn)
reo = open('tweetraw.txt', 'w')
reo.write(tl)
rnn = textgenrnn()
# train from tweets
rnn.train_from_file('tweetraw.txt')
#generate with 3 layers
geno = rnn.generate(3, temperature=1.0)
# post ai
final = manifest.PostUpdate(geno)
print(final.text)
import twitter
#Setting up Twitter API
api = twitter.api(
    consumer_key='JJFgGgN8neum0VTXsGO72F3Ex',
    consumer_secret='MZCljH6ndfJm8N4rt0ZReqQg6bv70NPu16eU89uf08L2lLXosK',
    access_token_key='2611457064-J1nZTCizycFuFqrGsY7HFdtRAlx7HNvl2wzhidr',
    access_token_secret='GraY5KHNJWCFpFxqrgko4xWCozoUvrQCRxAQy5VHtXzAO',
)

search = api.GetSearch(term='adventure',
                       lang='en',
                       result_type='recent',
                       count=10,
                       max_id='')
for t in search:
    print(t.user.screen_name + ' (' + t.created_at + ')')
    #Add the .encode to force encoding
    print(t.text.encode('utf-8'))
    print('')
예제 #15
0
import twitter

consumer_key = "dd4wfmFAp0dDIyBGozBDhPVAr"
consumer_secret = "CgUiQ06QbccXjNT4lnxJQqKOhgXVR2vvvQ6qN3u8RunwgQk5wa"
access_token_key = "24782lg8kqs2wZGR73200-ui6FNv0k63YuJxL1VI77YrqkdxK0"
access_token_secret = "UME9xsHbFUZ5BtEQYxDlp4HUVfbeVPNUCxvYB2uO1K6jU"

aapi = twitter.api(consumer_key=[consumer_key],
                   consumer_secret=[consumer_secret],
                   access_token_key=[access_token_key],
                   access_token_secret=[access_token_secret])

print(aapi.VerifyCredentials())