Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
679 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...