[英]Twitter app is not getting started
我寫了以下腳本從Twitter提取推文。
library("twitteR")
library("ROAuth")
library("RCurl")
library("httr")
download.file(url="http://curl.haxx.se/ca/cacert.pem",destfile="cacert.pem")
ck <- '4QPOQJoiBgoGP7jU13Akxfp2E'
cs <- 'ued02VUpial3K8NW8foectZj1UFtsEfQetQJbYXD21uCj0ohJc'
ak <- '136316586-xWnCMrE5UYSzigTOwTVyR4NH4gfR01adpR5SF5IK'
as <- 'zsIj4lsDc5xKcDyofWkYijKnUY8Uj71sg1NfaIFKZbGc2'
reqURL<- 'https://api.twitter.com/oauth/request_token'
acURL <- 'https://api.twitter.com/oauth/access_token'
auURL <- 'https://api.twitter.com/oauth/authorize'
cred <- OAuthFactory$new(consumerKey=ck,consumerSecret=cs,requestURL=reqURL,accessURL=acURL,authURL=auURL)
cred$handshake(cainfo="cacert.pem")
save(cred, file="twitter_authentication.Rdata")
load("twitter_authentication.Rdata")
oauth_endpoints("twitter")
myapp <- oauth_app("twitter",key=ck,secret=cs)
twitter_token <- oauth1.0_token(oauth_endpoints("twitter"), myapp)
setup_twitter_oauth(ck,cs)
search.string <- "#Bahubali"
no.of.tweets <- 10
tweets <- searchTwitter(search.string, n=no.of.tweets, lang="en")
tweets
write.csv(tweets, file='/home/horopter/tweet/CSVTweets.csv', row.names=F)
但是我得到了這個setup_twitter_oauth(ck,cs)[1]“使用基於瀏覽器的身份驗證”在瀏覽器中等待身份驗證...按Esc / Ctrl + C放棄
我被困在那里。 網站要么說“您沒有權限”。 或根本沒有打開。 如果我不提供回調網址,則不會進行身份驗證,否則將再次陷入上述問題。 幫幫我
我曾經嘗試使用相同的代碼和身份驗證令牌,但這是對我有用的代碼。 setup_twitter_oauth
需要所有ck, cs, ak, as
參數。
library("twitteR")
library("ROAuth")
library("RCurl")
library("httr")
download.file(url="http://curl.haxx.se/ca/cacert.pem",destfile="cacert.pem")
ck <- '4QPOQJoiBgoGP7jU13Akxfp2E'
cs <- 'ued02VUpial3K8NW8foectZj1UFtsEfQetQJbYXD21uCj0ohJc'
ak <- '136316586-xWnCMrE5UYSzigTOwTVyR4NH4gfR01adpR5SF5IK'
as <- 'zsIj4lsDc5xKcDyofWkYijKnUY8Uj71sg1NfaIFKZbGc2'
setup_twitter_oauth(ck,cs, ak, as)
search.string <- "#Bahubali"
下載.pem
文件后,這將設置身份驗證。 當要求進行身份驗證時,請按1。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.