Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
616 views
in Technique[技术] by (71.8m points)

twitter - Using R to send tweets

I saw a cute demonstration of tweeting from R in a presentation some months ago. The scratch code used by the presenter is here:

http://www.r-bloggers.com/twitter-from-r%E2%80%A6-sure-why-not/

the code is short and sweet: library("RCurl") opts <- curlOptions(header = FALSE, userpwd = "username:password", netrc = FALSE)

tweet <- function(status){
  method <- "http://twitter.com/statuses/update.xml?status="
  encoded_status <- URLencode(status)
  request <- paste(method,encoded_status,sep = "")
  postForm(request,.opts = opts)
}

With this function, you can send a tweet simply by using the update function:

tweet("This tweet comes from R! #rstats")

I thought that this could be a useful way of announcing when long jobs are completed. I tried to run this on my machine, and I got some error:

[1] " Basic authentication is not supported " attr(,"Content-Type") charset "application/xml" "utf-8" Warning message: In postForm(request, .opts = opts) : No inputs passed to form

I'm wondering if there has been some changes on the twitter end of this, that make this code produce this error? I don't know too much about getting R to talk to webpages, so any guidance is much appreciated!!

E

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Yes, the basic authentication scheme was disabled on the 16th August 2010.. You'll need to set it up to use OAuth. Unfortunately that is not nearly as simple as using basic authentication

See this twitter wiki page for more information and this StackOverflow question about OAuth for R.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...