def demo(): twitter = OAuth(client_key=key, client_secret=secret) header = twitter.auth_header(request_url) r = requests.post(request_url, headers={"Authorization": header}) token = parse_qs(r.text)["oauth_token"][0] auth = "{url}?oauth_token={token}".format(url=auth_url, token=token) return redirect(auth)
def demo(): twitter = OAuth(client_key=key, client_secret=secret) header = twitter.auth_header(request_url) r = requests.post(request_url, headers={"Authorization":header}) token = parse_qs(r.text)["oauth_token"][0] auth = "{url}?oauth_token={token}".format(url=auth_url, token=token) return redirect(auth)
def post_update(): post = { "status" : request.form["status_update"] } token_secret = session["token_secret"] access_token= session["access_token"] twitter = OAuth(client_key=key, client_secret=secret, token_secret=token_secret, access_token=access_token) header = twitter.auth_header(update_url, post) r = requests.post(update_url, data=post, headers={"Authorization": header}) return redirect("https://twitter.com/#!/%s" % session["screen_name"])
def post_update(): post = {"status": request.form["status_update"]} token_secret = session["token_secret"] access_token = session["access_token"] twitter = OAuth(client_key=key, client_secret=secret, token_secret=token_secret, access_token=access_token) header = twitter.auth_header(update_url, post) r = requests.post(update_url, data=post, headers={"Authorization": header}) return redirect("https://twitter.com/#!/%s" % session["screen_name"])
def callback(): verifier = request.args.get("oauth_verifier") token = request.args.get("oauth_token") twitter = OAuth(client_key=key, client_secret=secret, request_token=token, verifier=verifier) header = twitter.auth_header(access_url) r = requests.post(access_url, headers={"Authorization" : header}) info = parse_qs(r.text) session["access_token"] = info["oauth_token"][0] session["token_secret"] = info["oauth_token_secret"][0] session["screen_name"] = info["screen_name"][0] return """<html><head></head><body>
def callback(): verifier = request.args.get("oauth_verifier") token = request.args.get("oauth_token") twitter = OAuth(client_key=key, client_secret=secret, request_token=token, verifier=verifier) header = twitter.auth_header(access_url) r = requests.post(access_url, headers={"Authorization": header}) info = parse_qs(r.text) session["access_token"] = info["oauth_token"][0] session["token_secret"] = info["oauth_token_secret"][0] session["screen_name"] = info["screen_name"][0] return """<html><head></head><body>