Beispiel #1
0
def main():
    c = get_conf()
    o = OAuthHandler(c["consumer_key"], c["consumer_secret"])
    c["authorization_url"] = o.get_authorization_url()
    c["request_token"] = o.request_token
    print c["authorization_url"]
    verifier = raw_input("click the url above, then input the verifier: ")
    verifier = verifier.strip()
    c["verifier"] = verifier
    try:
        access_token = o.get_access_token(verifier)
        c["access_token_key"] = access_token.key
        c["access_token_secret"] = access_token.secret
        c["access_token"] = access_token.to_string()
        set_conf(c)
        print "oauth succeeded"
    except:
        print "oauth failed"
Beispiel #2
0
def main():
    c = get_conf()
    o = OAuthHandler(c['consumer_key'], c['consumer_secret'])
    c['authorization_url'] = o.get_authorization_url()
    c['request_token'] = o.request_token
    print c['authorization_url']
    verifier = raw_input('click the url above, then input the verifier: ')
    verifier = verifier.strip()
    c['verifier'] = verifier
    try:
        access_token = o.get_access_token(verifier)
        c['access_token_key'] = access_token.key
        c['access_token_secret'] = access_token.secret
        c['access_token'] = access_token.to_string()
        set_conf(c)
        print 'oauth succeeded'
    except:
        print 'oauth failed'
Beispiel #3
0
from qqweibo import OAuthHandler, API, JSONParser, ModelParser
from qqweibo.utils import timestamp_to_str
import urllib, urllib2, http_helper

a = OAuthHandler('801486043', 'cd0a763d5f7d8be4f588b0f6f290fb06')
a = OAuthHandler('801486692', '35499dde285b599841fcee05aee4e28b')
a = OAuthHandler('801486694','122efd9274999d8eb06b185501611ca0')
aaaaa = OAuthHandler('801486696','c45b2b1afb0eae1e64466f7c9fd36319')
aaaaa = OAuthHandler('801486704','f8a0cb0327d53a71aba609707c3ea239')
aaaaa = OAuthHandler('801486706','ccb88ca0bd2d2ab59465abf45818567e')

# use this
url = a.get_authorization_url()
print 'authorization url:' + url
verifier = raw_input('PIN: ').strip()
a.get_access_token(verifier)

# or directly use:
#token = 'your token'
#tokenSecret = 'your secret'
#a.setToken(token, tokenSecret)
'''rhhgjkli'''

api = API(a)

#me = api.user.info()
#print me.name, me.nick, me.location


#nba = api.user.userinfo('NBA')
Beispiel #4
0
    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)
# or you can use callback url
# auth = OAuthHandler(API_KEY, API_SECRET,
#     callback="http://localhost:5000/callback")
# will be callbackurl?oauth_token=[OAUTH_TOKEN]&oauth_verifier=[VERIFIER]

## use get_authorization_url if you haven't got a token
url = auth.get_authorization_url()
print ('Opening {:s} in your browser...'.format(url))
webbrowser.open_new(url)
verifier = input('Your PIN: ').strip()

access_token = auth.get_access_token(verifier)

# = Save Token =
token = access_token.key
tokenSecret = access_token.secret
print (("Access token key:    {:s}\n"
        "Access token secret: {:s}").format(token, tokenSecret))
## or if you already have token
# token = 'your token'
# tokenSecret = 'yourr tokenSecret'
# auth.setToken(token, tokenSecret)


# now you have a workable api
api = API(auth, parser=JSONParser())
# or use `api = API(auth)`