我在AWS“Ubuntu Server 12.04.2 LTS”上运行R Studio并通过我的浏览器访问R Studio。
当我尝试使用包ROAuth
并使用代码
credential<-OAuthFactory$new(consumerKey="xxxxx",
consumerSecret="xxxxx",
requestURL="https://api.twitter.com/oauth/request_token",
accessURL="https://api.twitter.com/oauth/access_token",
authURL="https://api.twitter.com/oauth/authorize")
credential$handshake()
registerTwitterOAuth(credential)
我在registerTwitterOAuth(credential)
说
Error in registerTwitterOAuth(credential) :
ROAuth is no longer used in favor of httr, please see ?setup_twitter_oauth
但是我找不到任何进一步的解释..
答案 0 :(得分:6)
显然twitteR软件包在我发布之前就已经更改了,所以验证的新方法是
setup_twitter_oauth(CUSTOMER_KEY, CUSTOMER_SECRET, ACCESS_TOKEN, ACCESS_secret, credentials_file=NULL)
答案 1 :(得分:1)
我遇到了setup_twitter_oauth()
函数的一些问题。我运行了以下代码,它对我没有任何错误。
library(RCurl)
require(twitteR)
library(ROAuth)
reqURL <- "https://api.twitter.com/oauth/request_token"
accessURL <- "https://api.twitter.com/oauth/access_token"
authURL <- "https://api.twitter.com/oauth/authorize"
api_Key <- "XXXXXXX"
api_Secret <- "XXXXXXXXXXXXXXXXX"
twitCred <- OAuthFactory$new(consumerKey=api_key,
consumerSecret=api_secret,
requestURL=reqURL,
accessURL=accessURL,
authURL=authURL
)
twitCred$handshake()
编辑:
刚刚对我的应用程序的access_token进行了排序,现在setup_twitter_oauth
功能正常运行。
如果生成api_key
,api_secret
,acsess_token
,access_token_secret
且没有错误,请使用以下代码对R进行Twitter身份验证。
api_key = "XXXXXXXXX" // your api_key
api_secret = "XXXXXXXXXX" // your api_secret
access_token = "XXXXXXXXXX" // your access_token
access_token_secret = "XXXXXXXXXX" // your access_token_sceret
setup_twitter_oauth(api_key,api_secret,access_token,
access_token_secret)
答案 2 :(得分:1)
以下对我有用:
obj.saveValueName = "a sample name";
Console.WriteLine(obj.saveValueName); // Outputs "a sample name"
答案 3 :(得分:1)
这是为我工作的R脚本:
library("twitteR")
library("ROAuth")
download.file(url= "http://curl.haxx.se/ca/cacert.pem", destfile= "cacert.pem")
credentials <- OAuthFactory$new(consumerKey='XXXXXXXXXXXXXXXXXX',
consumerSecret='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
requestURL='https://api.twitter.com/oauth/request_token',
accessURL='https://api.twitter.com/oauth/access_token',
authURL='https://api.twitter.com/oauth/authorize')
credentials$handshake(cainfo="cacert.pem")
save(credentials, file="twitter authentication.Rdata")
load("twitter authentication.Rdata")
setup_twitter_oauth(credentials$consumerKey, credentials$consumerSecret,
credentials$oauthKey, credentials$oauthSecret)
答案 4 :(得分:0)
我在使用setup_twitter_oauth函数时遇到了一些问题。 我运行以下代码,并在运行setup_twitter_oauth函数或加载凭证文件后没有得到对象。
然后我只加载cred_1.RData文件,我得到一个似乎没用的sig objetc。
我在Windows上安装了github版本的软件包。
rm(list = ls(,all=T))
setwd("D:\\TWEETS\\cuenta_1")
library(twitteR)
library(httr)
# Credenciales
consumer_key = "xxxxxxxxxxxxxxxx"
consumer_secret = "xxxxxxxxxxxxxxxx"
access_token = "xxxxxxxxxxxxxxxxxxx"
access_secret = "xxxxxxxxxxxxxxxx"
credentials_file = "cred_1.RData"
setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret, credentials_file)
load_twitter_oauth("cred_1.RData")
ls()
> ls()
[1] "access_secret" "access_token" "consumer_key" "consumer_secret"
[5] "credentials_file"
> load("cred_1.RData")
>
> ls()
[1] "access_secret" "access_token" "consumer_key" "consumer_secret" "credentials_file" "load_twitter_oauth" "set_oauth_sig"
[8] "sig"
>
> print(sig)
Config:
List of 1
$ signature:function (method, url)