Last active
October 7, 2015 15:08
-
-
Save atbradley/3184120 to your computer and use it in GitHub Desktop.
Post to Tumblr (as draft) when generating HTML from R Markdown (R Studio) No longer works--Tumblr's eliminated v1 of their API for everything but retrieving posts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#in .Rprofile: | |
tumblr.user <- "[email protected]" | |
tumblr.pass <- "tumblrPassword" | |
library(markdown) | |
library(httr) | |
options(rstudio.markdownToHTML = | |
function(i,o) { | |
markdownToHTML(i,o,fragment.only=TRUE) | |
#Post as a draft to Tumblr. | |
cat("\n","Enter a title, or a blank line for none.","\n") | |
title<-scan(what="character", n=1, sep="\n") | |
txt <- paste(readLines(o), collapse="\n") | |
body <- list(email = tumblr.user, | |
password = tumblr.pass, | |
type = "regular", | |
body = txt, | |
state = "draft") | |
#If no title was entered, don't send one to Tumblr. | |
if(length(title) == 1) body$title <- title | |
POST("http://www.tumblr.com/api/write", body=body) | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment