示例#1
0
文件: oauth.py 项目: go/geloge-lo
def authorize(oauth_token):
    uri = 'http://twitter.com/oauth/access_token'
    params = get_oauth_params(oauth_token = oauth_token)
    res = api_post(uri, params)
    if not res:
        return None

    res_param = parse_qs(res)

    if not res_param.has_key('oauth_token'):
        return None
    if not res_param.has_key('oauth_token_secret'):
        return None
    if not res_param.has_key('screen_name'):
        return None
    if not res_param.has_key('user_id'):
        return None
    
    return Token(
        oauth_token = res_param['oauth_token'][0], 
        oauth_token_secret = res_param['oauth_token_secret'][0], 
        time_created = datetime.now(), 
        screen_name = res_param['screen_name'][0],
        user_id = res_param['user_id'][0]
        )
示例#2
0
def request_token():
    uri = 'http://twitter.com/oauth/request_token'
    params = get_oauth_params()
    res = api_get(uri, params)
    if not res:
        return None

    res_param = parse_qs(res)

    if not res_param.has_key('oauth_token'):
        return None
    if not res_param.has_key('oauth_token_secret'):
        return None

    return Token(oauth_token=res_param['oauth_token'][0],
                 oauth_token_secret=res_param['oauth_token_secret'][0],
                 time_created=datetime.now())
示例#3
0
文件: oauth.py 项目: go/geloge-lo
def request_token():
    uri = 'http://twitter.com/oauth/request_token'
    params = get_oauth_params()
    res = api_get(uri, params)
    if not res:
        return None

    res_param = parse_qs(res)

    if not res_param.has_key('oauth_token'):
        return None
    if not res_param.has_key('oauth_token_secret'):
        return None

    return Token(
        oauth_token = res_param['oauth_token'][0], 
        oauth_token_secret = res_param['oauth_token_secret'][0], 
        time_created = datetime.now()
        )
示例#4
0
def authorize(oauth_token):
    uri = 'http://twitter.com/oauth/access_token'
    params = get_oauth_params(oauth_token=oauth_token)
    res = api_post(uri, params)
    if not res:
        return None

    res_param = parse_qs(res)

    if not res_param.has_key('oauth_token'):
        return None
    if not res_param.has_key('oauth_token_secret'):
        return None
    if not res_param.has_key('screen_name'):
        return None
    if not res_param.has_key('user_id'):
        return None

    return Token(oauth_token=res_param['oauth_token'][0],
                 oauth_token_secret=res_param['oauth_token_secret'][0],
                 time_created=datetime.now(),
                 screen_name=res_param['screen_name'][0],
                 user_id=res_param['user_id'][0])
示例#5
0
def rate_limit_status2(oauth_token, oauth_token_secret):
    params = get_oauth_params(oauth_token = oauth_token)
    url = 'http://api.twitter.com/1/account/rate_limit_status.json'
    return api_get(url, params, oauth_token_secret)