Пример #1
0
import sys
sys.path.insert(0, "..")

from qqweibo.auth import OAuthHandler
from qqweibo.api import API
from qqweibo.parsers import ModelParser

API_KEY = 'your key'
API_SECRET = 'your secret'

if API_KEY.startswith('your'):
    print u'必须正确填写 API_KEY 和 API_SECRET'
    raise SystemExit('You must set API_KEY and API_SECRET')

auth = OAuthHandler(API_KEY, API_SECRET)

token = 'your token'
tokenSecret = 'yourr tokenSecret'
auth.setToken(token, tokenSecret)

# this time we use ModelParser()
api = API(auth, parser=ModelParser())


"""
Avaliable API:
api.t.add
api.t.addmusic
api.t.addpic
api.t.addvideo
Пример #2
0
sys.path.insert(0, "..")

from qqweibo.auth import OAuthHandler
from qqweibo.api import API
from qqweibo.parsers import JSONParser
import webbrowser


API_KEY = 'your key'
API_SECRET = 'your secret'

if API_KEY.startswith('your'):
    print u'必须正确填写 API_KEY 和 API_SECRET'
    raise SystemExit('You must set API_KEY and API_SECRET')

auth = OAuthHandler(API_KEY, API_SECRET)

## use get_authorization_url if you haven't got a token
url = auth.get_authorization_url()
print 'Open', url, 'in your browser'
webbrowser.open_new(url)
verifier = raw_input('Your PIN: ').strip()
auth.get_access_token(verifier)

## or if you already have token
#token = 'your token'
#tokenSecret = 'yourr tokenSecret'
#auth.setToken(token, tokenSecret)


# now you have a workable api