Example #1
0
def main():
    consumer_key = 'API_KEY'
    consumer_secret = 'API_SECRET'

    tumblr_oauth = TumblrOAuthClient(consumer_key, consumer_secret)

    authorize_url = tumblr_oauth.get_authorize_url()
    print "Visit: %s" % authorize_url

    oauth_verifier = raw_input('What is the oauth_verifier?')
    access_token = tumblr_oauth.get_access_token(oauth_verifier)
    print "Access key:", access_token.key
    print "Access Secret:", access_token.secret
  def authPart1(self):
    from tumblr.oauth import TumblrOAuthClient
    self.tumblr_oauth = TumblrOAuthClient(self.api_key, self.api_secret)

    auth_url = self.tumblr_oauth.get_authorize_url()

    return auth_url
import os
import sys
from tumblr.oauth import TumblrOAuthClient

if not os.environ.get("KEY", None):
    sys.exit("Give app key as KEY env")

if not os.environ.get("SECRET", None):
    sys.exit("Give app key as SECRET env")

if not os.environ.get("BLOG", None):
    sys.exit("Give blog URL as BLOG env")

callback = "http://example.com/callback/"

tumblr_oauth = TumblrOAuthClient(os.environ["KEY"], os.environ["SECRET"])

auth_url = tumblr_oauth.get_authorize_url()

print "Connect with Tumblr via:\n%s\nThen pick oauth_verifier from the url" % auth_url

oauth_verifier = raw_input('Verifier: ').strip()

access_token = tumblr_oauth.get_access_token(oauth_verifier)

final_oauth_token = access_token.key
final_oauth_token_secret = access_token.secret

# Genereate the upload script which has credentials stored
out = open("upload.sh", "wt")
Example #4
0
import sys
from tumblr.oauth import TumblrOAuthClient


if not os.environ.get("KEY", None):
    sys.exit("Give app key as KEY env")

if not os.environ.get("SECRET", None):
    sys.exit("Give app key as SECRET env")

if not os.environ.get("BLOG", None):
    sys.exit("Give blog URL as BLOG env")

callback = "http://example.com/callback/"

tumblr_oauth = TumblrOAuthClient(os.environ["KEY"], os.environ["SECRET"])

auth_url = tumblr_oauth.get_authorize_url()

print "Connect with Tumblr via:\n%s\nThen pick oauth_verifier from the url" % auth_url

oauth_verifier = raw_input('Verifier: ').strip()

access_token = tumblr_oauth.get_access_token(oauth_verifier)

final_oauth_token = access_token.key
final_oauth_token_secret = access_token.secret

# Genereate the upload script which has credentials stored
out = open("upload.sh", "wt")
class TumblrObject(OAuthObjectBase):
  def __init__(self):
    OAuthObjectBase.__init__(self)
    self.apiName = "tumblr"

  def authPart1(self):
    from tumblr.oauth import TumblrOAuthClient
    self.tumblr_oauth = TumblrOAuthClient(self.api_key, self.api_secret)

    auth_url = self.tumblr_oauth.get_authorize_url()

    return auth_url

  def authPart2(self, oauth_verifier):
    access_token = self.tumblr_oauth.get_access_token(oauth_verifier)

    print "Access key:", access_token.key
    print "Access Secret:", access_token.secret

    self.final_oauth_token = access_token.key
    self.final_oauth_token_secret = access_token.secret

    authDict = authPickler.getAuthDict(self.apiName)
    authDict["final_oauth_token"] = self.final_oauth_token
    authDict["final_oauth_token_secret"] = self.final_oauth_token_secret
    authPickler.setAuthDict(self.apiName, authDict)
    self.authorised = True

    self.setupAPI()

    return redirectToUrlText(web.ctx.homedomain)

  def setupAPI(self):
    hostname = self.publishURL
    consumer = oauth.Consumer(self.api_key, self.api_secret)
    token = oauth.Token(self.final_oauth_token, self.final_oauth_token_secret)
    self.tumblr = TumblrClient(hostname, consumer, token) 


  def postTestPost(self):
    params = {
      'type': 'text',
      'body': 'testPost'
    }
    json_response = self.tumblr.create_post(request_params=params)
    if json_response["meta"]["status"] != 201:
      raise Exception("Tumblr upload error!")   
    
  def postImagePost(self, jobDict):
    captionString = ""
    
    if jobDict["title"] != None:
      captionString = "<strong>" + jobDict["title"] + "</strong><br/>"
    if jobDict["description"] != None:
      captionString += jobDict["description"]
      
    params = {
        'type':'photo',
        'caption': captionString,
        'link': jobDict["flickrurl"],
        'source': jobDict["flickrImageLargeUrl"],
        'tags': ','.join(jobDict["tags"])
    }
        
    json_response = self.tumblr.create_post(request_params=params)
    if json_response["meta"]["status"] != 201:
      print "TUMBLR ERROR"
      print json_response
      raise Exception("Tumblr upload error!")
Example #6
0
from tumblr.oauth import TumblrOAuthClient

consumer_key = 'BmyWZMbAzcK9Y7mEQKTgf1JI4icFlXvfxxkfIzuG9nFFVJfg9Q'
consumer_secret = 'p5ohAI2hT7tSwjVCI0HA8oTpOYAvc3m6tIPAXJGNXkur6PgQdT'

tumblr_oauth = TumblrOAuthClient(consumer_key, consumer_secret)
authorize_url = tumblr_oauth.get_authorize_url()

print "visit: %s" % authorize_url

oauth_verifier = raw_input('What is the oauth_verifier?')
access_token = tumblr_oauth.get_access_token(oauth_verifier)
print "Access key:", access_token.key
print "Access Secret:", access_token.secret