Exemplo n.º 1
0
import webbrowser
from qqweibo import API, JSONParser
from qqweibo import OAuth2_0_Handler as AuthHandler
import secret

# for py3k
try:
    input = raw_input
except:
    pass

API_KEY = secret.apiKey
API_SECRET = secret.apiSecret
CALLBACK_URL = secret.callbackUrl

auth = AuthHandler(API_KEY, API_SECRET, CALLBACK_URL)

## 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 CODE: ').strip()

token = auth.get_access_token(verifier)

print token
# = Save Token =

# now you have a workable api
api = API(auth, parser=JSONParser())
# or use `api = API(auth)`
Exemplo n.º 2
0
import webbrowser

from qqweibo import API
from qqweibo import OAuth2_0_Handler as AuthHandler

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')

CALLBACK_URL = 'http://fledna.duapp.com/query'

auth = AuthHandler(API_KEY, API_SECRET, CALLBACK_URL)


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
Exemplo n.º 3
0
from qqweibo import API, JSONParser
from qqweibo import OAuth2_0_Handler as AuthHandler
import secret

# for py3k
try:
    input = raw_input
except:
    pass


API_KEY = secret.apiKey
API_SECRET = secret.apiSecret
CALLBACK_URL = secret.callbackUrl

auth = AuthHandler(API_KEY, API_SECRET, CALLBACK_URL)


## 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 CODE: ").strip()

token = auth.get_access_token(verifier)

print token
# = Save Token =


# now you have a workable api