Example #1
0
from flask import Flask, render_template, session, url_for, redirect, request, flash, make_response
import config
import oauth2 as oauth
import redis
import urlparse
from urllib import urlencode
import redis
import json

app = Flask(__name__)
app.secret_key = config.consumer_key
app.consumer = oauth.Consumer(key=config.consumer_key, secret=config.consumer_secret)
app.cache = redis.StrictRedis(host="localhost", port=6379, db=0)

site_url = "http://127.0.0.1:5000/"


def verify_response(resp):
    if resp["status"] != "200":
        session.pop("request_token", None)
        flash("Bad response from Twitter: {0}".format(resp))
        return redirect(url_for("index"))
    else:
        return None


@app.route("/", methods=["GET"])
def index():
    if "request_token" in session:
        auth_token = oauth.Token(
            session["request_token"]["oauth_token"], session["request_token"]["oauth_token_secret"]
Example #2
0
import oauth2 as oauth
import config
import urlparse
from flask import Flask, redirect, url_for, session, render_template, request, flash, make_response
from urllib import urlencode
import time
import json
import twitter
import redis

app = Flask(__name__)
app.secret_key = config.CKEY
app.consumer = oauth.Consumer(key=config.CKEY, secret=config.CSEC)
app.cache = redis.StrictRedis(host="localhost", port=6379, db=0)


def verify_response(resp):
    if resp["status"] != "200":
        session.pop("request_token", None)
        flash("Bad response from Twitter: {0}".format(resp))
        return redirect(url_for("index"))
    else:
        return None


def get_tweets(client):
    """Queries Twitter API for user tweets until it gets 0 back.
	Concatenates and returns tweets."""
    tweets = []
    page = 1
    while True:  # repeat until tweet supply is exhausted