# Posting to Tumblr with Ruby

**URL:** <https://www.ruby-forum.com/t/posting-to-tumblr-with-ruby/187540>\
**Category:** Ruby\
**Created:** [April 25, 2010, 9:30am UTC](https://www.ruby-forum.com/t/posting-to-tumblr-with-ruby/187540 "2010-04-25T09:30:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidtl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/35a633/32.png) [@davidtl](https://www.ruby-forum.com/u/davidtl)\
**Post date:** [April 25, 2010, 9:30am UTC](https://www.ruby-forum.com/t/posting-to-tumblr-with-ruby/187540/1 "2010-04-25T09:30:25Z")

</div>

I’m a Ruby/programming noob and one piece of advice I keep seeing pop up  
from Ruby “gurus” is that you should play with real code and build real  
things. Seeing as I would one day like to build a Tumblr client with  
MacRuby, I thought I’d get acquainted with the process via Ruby on its  
lonesome.

Problem is, like I said, I’m a noob and I have no idea what I’m doing.

I found the “tumblr-rb” gem ([GitHub - mwunsch/tumblr: Command line interface and Ruby client for the Tumblr API (v2)](http://github.com/mwunsch/tumblr)) which  
I’ve installed, and have successfully posted to Tumblr via the command  
line, but I have no idea how to use/manipulate this sample code:

request = Tumblr.new(username, password).post(document)  
request.perform do |response|  
if response.success?  
puts response.body # Returns the new post’s id.  
else  
puts “Something went wrong: #{response.code}  
#{response.message}”  
end  
end

Would appreciate any direction you could give me. 🙂

---

<div class="post-metadata">

**Author:** ![davidtl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/35a633/32.png) [@davidtl](https://www.ruby-forum.com/u/davidtl)\
**Post date:** [April 29, 2010, 10:37am UTC](https://www.ruby-forum.com/t/posting-to-tumblr-with-ruby/187540/2 "2010-04-29T10:37:47Z")

</div>

David T. wrote:

> request = Tumblr.new(username, password).post(document)  
> request.perform do |response|  
> if response.success?  
> puts response.body # Returns the new post’s id.  
> else  
> puts “Something went wrong: #{response.code}  
> #{response.message}”  
> end  
> end
> 
> Would appreciate any direction you could give me. 🙂

Are you only wanting to include this code in your client ?  
I am not clear on what you wish to do. From what i can see,

1. document will be a text field containing what the user wishes to  
post.  
So you’ve already accepted username, password and document from user.

2. Most likely you would not want to print (puts) the error or response  
onto the terminal since you are in macruby.

You can make a method of this and return the id, or return the success  
or failure boolean and store id and message in some instance of the  
class.

Then you would display the id to the user with success message, or store  
it in some log file along with message or error message.

I am sorry i don’t know macruby so can’t help you on what to do on that  
end.
