Code Examples

curl example

Access the service using curl at the command line.

Github Hubot example

Access the service using Github's Hubot

Post to Tumblr example

CapGun "Dog Food's" its own API into a Tumblr at We started to do this even before CapGun was opened to the public to be sure we were building the service towards a real working goal.

This example is how you can do the same to automate posting captures of URLs from your Twitter feed into your Tumblr. This requires obtaining an OAuth token and secret for the API allowing an external application to post to your Tumblr. Tumblr's OAuth page is at You will also have to create a Twitter app in the context of their developer panel and obtain OAuth credentials for that app as well to gather URLs that are posted in your Twitter feed.

Generate OAuth keys for Tumblr and Twitter APIs

We've built a micro Ruby Gem, an example is below, to make it easier to generate your Tumblr API OAuth keys.

# a micro Ruby Gem to generate Tumblr API OAuth keys
mkdir /path/to/some/new/dir
cd /path/to/some/new/dir
bundle install
bundle exec generate-token

Next, go through the steps to configure a Twitter application in their developer panel and obtain the OAuth credentials for that application. and

Create script to watch Twitter for URLs and post them to service

Now, we'll build a script that will watch your Twitter timeline picking off new URLs posted by people you follow. When the watcher sees a new URL it will create a CapGun job to capture that URL. After that, we'll build a Sinatra application that will respond to CapGun's post receive hook when jobs are completed and submit the images in the job to posted to the Tumblr.

If you are lazy you can use our watcher scripts.

Create a Sinatra application to catch web hook callbacks and post the results to Tumblr

We've created a simple Sinatra app that you can use outright or as an example to trigger capgun capture images to the Tumblr API.