async def main(): async with Tweeter( AiohttpTweeterSession(), # required for oauth1 signing: APP_KEY, APP_KEY_SECRET, # optionally necessary for endpoints requiring a user's scope: access_token=ACCESS_TOKEN, access_token_secret=ACCESS_TOKEN_SECRET ) as tweeter: user_timeline = await tweeter.statuses.user_timeline() print(user_timeline)
async def main(): tweeters = { name: Tweeter(AiohttpTweeterSession(), os.environ[name + "_APP_KEY"], os.environ[name + "_APP_KEY_SECRET"], access_token=os.environ[name + "_ACCESS_TOKEN"], access_token_secret=os.environ[name + "_ACCESS_TOKEN_SECRET"]) for name in ("RB1", "RB2", "RB3", "RB4") } for name, tweeter in tweeters.items(): print(f'User: {name}') credentials = await tweeter.account.verify_credentials() print(f"{name}: {credentials['screen_name']}") user_timeline = await tweeter.statuses.user_timeline( screen_name=credentials['screen_name'], trim_user=False) print(user_timeline) # lookup_tweets = await tweeter.statuses.lookup(ids=[1313175713030209536]) # print(lookup_tweets) # search_results = await tweeter.search.tweets('python', count=5) # print(search_results) # account_settings = await tweeter.account.settings() # print(account_settings) # watch the random sampling of tweets chosen by twitter # async for tweet in tweeter.stream.sample(): # print(tweet) # async for tweet in tweeter.stream.filter( # track=['#python'], # locations=[ # ((-122.75, 36.8), (-121.75, 37.8)), # ((-74, 40), (-73, 41)) # ], # ): # print(tweet['text']) # result = await tweeter.statuses.update('Test message') # print(result) for tweeter in tweeters.values(): await tweeter.close()
def make_application() -> Application: tweeter = Tweeter( BareTweeterSession(), # required for oauth1 signing: os.environ["APP_KEY"], os.environ["APP_KEY_SECRET"], access_token=os.environ["ACCESS_TOKEN"], access_token_secret=os.environ["ACCESS_TOKEN_SECRET"]) app = Application(info=dict(tweeter=tweeter), middlewares=[CORSMiddleware()]) add_graphene(app, SCHEMA) return app
async def main(): tweeter = Tweeter(AiohttpTweeterSession(), os.environ["APP_KEY"], os.environ["APP_KEY_SECRET"], access_token=os.environ["ACCESS_TOKEN"], access_token_secret=os.environ["ACCESS_TOKEN_SECRET"]) params = ['paulg', 'evhead', 'jack', 'robblackbourn'] for name in params: timeline = await tweeter.statuses.user_timeline(screen_name=name, include_rts=False) print(f"{name}: {len(timeline)}") await tweeter.close() print('done')
async def main(): tweeter = Tweeter( BareTweeterSession(), # required for oauth1 signing: APP_KEY, APP_KEY_SECRET, # optionally necessary for endpoints requiring a user's scope: access_token=ACCESS_TOKEN, access_token_secret=ACCESS_TOKEN_SECRET) # user_timeline = await tweeter.statuses.user_timeline() # print(user_timeline) # lookup_tweets = await tweeter.statuses.lookup(ids=[1313175713030209536]) # print(lookup_tweets) # search_results = await tweeter.search.tweets('python', count=5) # print(search_results) # account_settings = await tweeter.account.settings() # print(account_settings) account_verify_credentials = await tweeter.account.verify_credentials() print(account_verify_credentials) # # watch the random sampling of tweets chosen by twitter # async for tweet in tweeter.stream.sample(): # print(tweet) # async for tweet in tweeter.stream.filter( # track=['#python'], # locations=[ # ((-122.75, 36.8), (-121.75, 37.8)), # ((-74, 40), (-73, 41)) # ] # ): # print(tweet) # result = await tweeter.statuses.update('Test message') # print(result) await tweeter.close()
async def main(): async with Tweeter( AiohttpTweeterSession(), os.environ["APP_KEY"], os.environ["APP_KEY_SECRET"], access_token=os.environ["ACCESS_TOKEN"], access_token_secret=os.environ["ACCESS_TOKEN_SECRET"]) as tweeter: params = [ ('PYTHON', ['#python'], [((-122.75, 36.8), (-121.75, 37.8))]), ('JAVA', ['#java'], [((-122.75, 36.8), (-121.75, 37.8))]), ('CSHARP', ['#csharp'], [((-122.75, 36.8), (-121.75, 37.8))]), ] tasks = { asyncio.create_task(run_stream(tweeter, name, track, locations)) for name, track, locations in params } await asyncio.wait(tasks)