你可以用pacakge ROAuth
來做到這一點。我假設你已經使用Twitter註冊了你的應用程序並擁有一個API密鑰。我在Stack Overflow上將other questions拼湊在一起(該問題和相關答案還包含一些指向其他貢獻問題的鏈接)以及包ROAuth
和twitteR
的文檔。
library(RCurl)
library(twitteR)
library(ROAuth)
requestURL <- "https://api.twitter.com/oauth/request_token"
accessURL = "http://api.twitter.com/oauth/access_token"
authURL = "http://api.twitter.com/oauth/authorize"
consumerKey = "myconsumerkeystring"
consumerSecret = "myconsumersecretstring"
Cred <- OAuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret,
requestURL=requestURL,
accessURL=accessURL,
authURL=authURL)
#The next command provides a URL which you will need to copy and paste into your favourite browser
#Assuming you are logged into Twitter you will then be provided a PIN number to type into the R command line
Cred$handshake(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))
# Checks that you are authorised
registerTwitterOAuth(Cred)
我認爲,使用流API是通過使用`twitteR`包封裝streamR
HTH
您是否嘗試過處理? http://cran.r-project.org/web/packages/twitteR/index.html – 2013-02-25 02:35:15
@AndyBarbour,twitteR不幸處理流式API。這非常有用,但不是爲此目的:/ – 2013-02-25 03:43:01
@ R-Enthusiast下面的解決方案適用於您嗎? – 2013-02-25 21:20:26