(October 2012) Tumblr has deprecated its v1 API, so that only reading functions now work in RTumblr. I'm currently looking at how to best implement the new OAuth API.
--
RTumblr is a R interface to the Tumblr API v1. It can be used to read and write tumblogs directly from R.
The main goal is to facilitate technical/R blogging directly from your R IDE. The end-to-end solution for this is not quite there yet.
First, you will need dependencies XML
and RCurl
.
install.packages("XML")
install.packages("RCurl")
For now, the easiest way to install RTumblr is to use the devtools
package to get the latest version straight from Github. Install the devtools
package if you do not have it yet:
install.packages("devtools")
Then load devtools
and install RTumblr
from Github.
library(devtools)
install_github("RTumblr", username = "fcocquemas")
Reading from a given tumblog is easy and can be done without logging in.
url <- "demo.tumblr.com"
tumblrRead(url)
tumblrRead(url, start=2, num=1)
tumblrRead(url, id=459009076)
tumblrRead(url, tagged="funny", filter="none")
To read drafts, queued and submitted posts from a tumblog you own, you need to authenticate with your email and password.
url2 <- "(YOU).tumblr.com"
user <- list(email="XXXXX@example.com", password="XXXXXX")
tumblrRead(url2, user=user, state="draft")
You can easily obtain information about your tumblogs.
user <- list(email="XXXXX@example.com", password="XXXXXX")
tumblrAuthenticate(user)
This needs to be expanded (and tested more). Here is a basic example of writing a regular post.
url <- "(YOU).tumblr.com"
user <- list(email="XXXXX@example.com", password="XXXXXX")
regular_post <- list(type="regular", title="Lorem ipsum",
body="**Hello** _world_")
tumblrWrite(url, user, regular_post)
You can provide various parameters, e.g. here to send it to the drafts rather than publish directly, not sending a twitter update if they are set up, specifying a given (past) date, and that the input format is markdown.
tumblrWrite(url, user, regular_post, state="draft", send_to_twitter="no",
date="2012-07-01 14:50:04", format="markdown")
Posting successfully will return a post ID, which you can reuse (in a post_id=
parameter) to update the post, e.g. publish it from drafts.
RTumblr is released under the MIT licence.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.