Lecture 9 (その2): twitteR
Twitterアプリケーションの登録
OAuth 認証用
https://dev.twitter.com
ROAuth, twitteRのインストール
install.packages("twitteR")
install.packages("ROAuth")
ROAuth, twitteRのインストールの読み込み
library(twitteR)
library(ROAuth)
twitteRからのOauth認証
cacert.pemをダウンロード
download.file(url = "http://curl.haxx.se/ca/cacert.pem", destfile = "cacert.pem")
認証情報(Twitterアプリケーション)
consr_key = "***********"
consr_secrt = "***********"
req_url = "https://api.twitter.com/oauth/request_token"
acs_url = "https://api.twitter.com/oauth/access_token"
auth_url = "https://api.twitter.com/oauth/authorize"
cred <- OAuthFactory$new(consumerKey = consr_key, consumerSecret = consr_secrt,
requestURL = req_url, accessURL = acs_url, authURL = auth_url)
handshake: twitterクライアント接続
cred$handshake(cainfo = "cacert.pem")

OAuth認証の登録
registerTwitterOAuth(cred)
検索例
searchTwitter("#olympics", n = 10)
userTimeline(username)