Beispiel #1
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]
        )
Beispiel #2
0
def update(status,
           lat = None, 
           lng = None, 
           display_coordinates = 'false',  
           oauth_token = None, 
           oauth_token_secret = None):
    params = get_oauth_params(oauth_token = oauth_token)
    params['status']  = status

    if lat:
        params['lat'] = lat
    if lng:
        params['long'] = lng

    url = 'http://api.twitter.com/1/statuses/update.json'
    result = api_post(url, params, oauth_token_secret)
    if not result:
        return None

    ret = json.loads(result)
    return ret
Beispiel #3
0
def update(status,
           lat=None,
           lng=None,
           display_coordinates='false',
           oauth_token=None,
           oauth_token_secret=None):
    params = get_oauth_params(oauth_token=oauth_token)
    params['status'] = status

    if lat:
        params['lat'] = lat
    if lng:
        params['long'] = lng

    url = 'http://api.twitter.com/1/statuses/update.json'
    result = api_post(url, params, oauth_token_secret)
    if not result:
        return None

    ret = json.loads(result)
    return ret
Beispiel #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])