Beispiel #1
0
def twitter_auth():
    oauth_verifier = request.args.get('oauth_verifier')
    # access_token cannot be used more than once
    access_token = get_access_token(session['request_token'], oauth_verifier)

    user = User.load_db_by_screen_name(access_token['screen_name'])
    if not user:
        user = User(access_token['screen_name'], access_token['oauth_token'],
                    access_token['oauth_token_secret'], id=None)
        user.save_to_db()

    session['screen_name'] = user.screen_name

    return redirect(url_for('profile'))
Beispiel #2
0
user = User.load_db_by_email(user_email)

if user:
    print("Signed in under email: {} ".format(user_email))
else:

    print("There is no login with email={} \n".format(user_email))

    request_token = get_request_token()

    oauth_verifier = get_oauth_verifier(request_token)

    access_token = get_access_token(request_token, oauth_verifier)

    first_name = input("Enter your first name: ")
    last_name = input("Enter your last name: ")

    user = User(user_email,
                first_name,
                last_name,
                access_token['oauth_token'],
                oauth_token_secret=access_token['oauth_token_secret'],
                id=None)
    user.save_to_db()

tweets = user.twitter_requests(
    'https://api.twitter.com/1.1/search/tweets.json?q=computers+filter:images')

for tweet in tweets['statuses']:
    print(tweet['text'])