def get_api(): import sys, os.path sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from qqweibo import OAuthHandler, API 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("qq: you should run get_oauthed.py first.\n")
def get_api(): import sys, os.path sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from qqweibo import OAuthHandler, API 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("qq: you should run get_oauthed.py first.\n")
a = OAuthHandler(API_KEY, API_SECRET) def get_token(): print a.get_authorization_url() verifier = raw_input('PIN: ').strip() print a.get_access_token(verifier) # or directly use: #token = 'e9fc735b76ba4e75a6ebaefe61ee66fc' token = 'd169abff38d747cfa8bdb21123577482' #tokenSecret = 'ec07bda1b332156d1554470893b16b6d' tokenSecret = '25d60b4c67c488a4d5291dcb9bd43fd8' a.setToken(token, tokenSecret) api = API(a) QQ_WEIBO_INFO_SOURCE_ID = 7 def search_for_new_statuses(): previous_real_count = session.query(Status).filter( Status.info_source_id == QQ_WEIBO_INFO_SOURCE_ID).count() lasttime = session.query(Job).filter( Job.info_source_id == QQ_WEIBO_INFO_SOURCE_ID).order_by( Job.id.desc()).first() deltatime = lasttime.previous_executed - timedelta(hours=2) starttime = time.mktime(deltatime.timetuple())
def getApi(token,secret): auth = OAuthHandler(webSetting.qqconsumer_key, webSetting.qqconsumer_secret) auth.setToken(token, secret) api = API(auth) return api
API_KEY = 'your key' API_SECRET = 'your secret' if API_KEY.startswith('your'): print ('You must fill API_KEY and API_SECRET!') webbrowser.open("http://open.t.qq.com/apps_index.php") raise RuntimeError('You must set API_KEY and API_SECRET') auth = OAuthHandler(API_KEY, API_SECRET) token = YOUR TOKEN HERE tokenSecret = YOUR TOKEN_SECRET HERE auth.setToken(token, tokenSecret) # this time we use ModelParser() api = API(auth) # ModelParser is the default option """ Avaliable API: Do to refer api.doc.rst api.user.info api.user.otherinfo api.user.update api.user.updatehead api.user.userinfo """