tumblr / pytumblr

A Python Tumblr API v2 Client
Apache License 2.0
723 stars 196 forks source link

How do I get pytumblr into my project and get it running? #144

Closed berkipekoglu closed 3 years ago

berkipekoglu commented 3 years ago

I'm new to Python. I am trying to use Pytumblr. I installed it with pip install pytumblr. and

git clone https://github.com/tumblr/pytumblr.git
cd pytumblr
python setup.py install

I completed the steps. I entered my consumer key information.

How can I run client.info() now? I mean, how do I get pytumblr into my project and get it running?

sndsgd commented 3 years ago

here is a sample script:

import json
from pytumblr import TumblrRestClient
from pprint import pprint

creds = json.load(open('./creds.json'))

client = TumblrRestClient(
    creds['consumer_key'],
    creds['consumer_secret'],
    creds['access_token'],
    creds['access_token_secret'],
)

response = client.info()
pprint(response)

it assumes that you're storing you credentials in a file formatted like so:

{
    "consumer_key": "...",
    "consumer_secret": "...",
    "access_token": "...",
    "access_token_secret": "...",
    "blog": "{name}.tumblr.com"
}

please make sure not to commit the credentials file!

berkipekoglu commented 3 years ago

here is a sample script:

import json
from pytumblr import TumblrRestClient
from pprint import pprint

creds = json.load(open('./creds.json'))

client = TumblrRestClient(
    creds['consumer_key'],
    creds['consumer_secret'],
    creds['access_token'],
    creds['access_token_secret'],
)

response = client.info()
pprint(response)

it assumes that you're storing you credentials in a file formatted like so:

{
    "consumer_key": "...",
    "consumer_secret": "...",
    "access_token": "...",
    "access_token_secret": "...",
    "blog": "{name}.tumblr.com"
}

please make sure not to commit the credentials file!

Thank you so much! i know how to use now. You are wonderful.