Пример #1
0
def getAccessToken(oauth_verifier, oauth_token, oauth_token_secret):
    vprint("GET ACCESS TOKEN")
    consumer = oauth.Consumer(consumer_key, consumer_secret)
    token = oauth.Token(oauth_token, oauth_token_secret)
    token.set_verifier(oauth_verifier)
    client = oauth.Client(consumer, token)
    resp, content = client.request(access_token_url, "POST")
    vprint("RESP", resp)
    access_token = dict(urlparse.parse_qsl(content))
    return access_token
Пример #2
0
def getAccessToken(oauth_verifier,oauth_token,oauth_token_secret):
  vprint("GET ACCESS TOKEN with ",oauth_token,oauth_token_secret)
  consumer = oauth.Consumer(consumer_key, consumer_secret)
  token = oauth.Token(oauth_token,oauth_token_secret)
  token.set_verifier(oauth_verifier)
  client = oauth.Client(consumer, token)
  resp, content = client.request(access_token_url, "POST")
  vprint("RESP",resp,content)
  if resp['status'] != '200':
    raise Exception(("Invalid response %s." % resp['status'])+content)

  access_token = dict(urlparse.parse_qsl(content))
  return access_token
Пример #3
0
def requestToken():
  vprint("REQUEST TOKEN")
  consumer = oauth.Consumer(consumer_key, consumer_secret)
  client = oauth.Client(consumer)
  """ Step 1: Get a request token. This is a temporary token that is used for 
  having the user authorize an access token and to sign the request to obtain
  said access token."""
  resp, content = client.request(request_token_url, "POST")
  vprint("RESPONSE",resp,content)
  if resp['status'] != '200':
    raise Exception("Invalid response %s." % resp['status'])
  request_token = dict(urlparse.parse_qsl(content))
  return request_token
Пример #4
0
def getUserInfo(token, token_secret):
    vprint("getUserInfo")
    vprint("token", token)
    vprint("Secret", token_secret)
    consumer = oauth.Consumer(consumer_key, consumer_secret)
    token = oauth.Token(token, token_secret)
    client = oauth.Client(consumer, token)
    info_url = "http://api.tumblr.com/v2/user/info"
    resp, content = client.request(info_url, "GET")
    if resp['status'] != '200':
        raise Exception("Invalid response %s." % resp['status'])

    vprint("RESP", resp)
    return content
Пример #5
0
def getUserInfo(token,token_secret):
  vprint("getUserInfo")
  vprint("token",token)
  vprint("Secret",token_secret)
  consumer = oauth.Consumer(consumer_key, consumer_secret)
  token = oauth.Token(token,token_secret)
  client = oauth.Client(consumer, token)
  info_url = "http://api.twitter.com/1.1/account/settings.json"
  resp,content = client.request(info_url,"GET")
  vprint("twitter returned",resp,content)
  if resp['status'] != '200':
    raise Exception("Invalid response %s." % resp['status'])

  vprint("RESP",resp)
  return content
Пример #6
0
def post(token, token_secret, blog, params):
    vprint("POST to ", blog)
    vprint("token", token)
    vprint("Secret", token_secret)
    consumer = oauth.Consumer(consumer_key, consumer_secret)
    token = oauth.Token(token, token_secret)
    client = oauth.Client(consumer, token)
    post_url = "http://api.tumblr.com/v2/blog/" + blog + "/post"
    pen = urllib.urlencode(params)
    resp, content = client.request(post_url, "POST", body=pen)
    if resp['status'] != '201':
        raise Exception("Invalid response %s." % resp['status'])

    vprint("RESP", resp, content)
    return content
    """