def get_weibo_user(): auth = OAuthHandler(consumer_key, consumer_secret) # Get currrent user access token from session access_token = session['oauth_access_token'] auth.setToken(access_token.key, access_token.secret) api = API(auth) # Get info from weibo return api.me()
def get_api(): import sys, os.path sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from weibopy import OAuthHandler, API, WeibopError c = get_conf() try: o = OAuthHandler(c['consumer_key'], c['consumer_secret']) o.setToken(c['access_token_key'], c['access_token_secret']) except KeyError, e: sys.stderr.write("you should run get_oauthed.py first.\n")
def get_api(consumer_key,consumer_sercet,access_token_key,access_token_sercet,access_token,user_name,server_user_name,server='sina'): import sys, os.path sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) sys.path.append(os.path.join(DIR_PATH,'../')) from weibopy import OAuthHandler, API, WeibopError from db import * sdb = session.query(TWDBS).filter(TWDBS.consumer_key==consumer_key,TWDBS.consumer_secret==consumer_secret,TWDBS.user_name==user_name,TWDBS.server_user_name==server_user_name,TWDBS.server==server).all()[-1] try: o = OAuthHandler(consumer_key, consumer_secret) o.setToken(sdb.access_token_key,sdb.access_token_secret) except KeyError, e: sys.stderr.write("you should run get_oauthed.py first.\n")