2012-02-21 30 views
4

我目前正在於從R發送微博,但我不能圍繞以下錯誤提示:Twitter和ROAuth

Error in .self$twFromJSON(out) : 
    Error: Could not authenticate with OAuth. 

我跟隨在twitter上的小插曲中的指示,關於該事項的其他計算器問題( http://stackoverflow.com/questions/8122879/roauth-on-windows-using-r),但似乎沒有解決這個錯誤。這裏是我使用的代碼:

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 = "*****************************" 
consumerSecret = "************************" 
Cred <- OAuthFactory$new(consumerKey=consumerKey, 
          consumerSecret=consumerSecret, 
          requestURL=requestURL, 
          accessURL=accessURL, 
          authURL=authURL) 
Cred$handshake(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")) 
registerTwitterOAuth(Cred) 

通過這裏工作。 registerTwitterOAuth返回TRUE,所以你會認爲一切正常。但是當我嘗試發送推文時,我收到上面列出的錯誤。

我試圖做派鳴叫:

tweet("text to tweet") 

這導致:

Error in .self$twFromJSON(out) : 
    Error: Could not authenticate with OAuth. 

不知道發生了什麼錯誤。 OAuth驗證似乎可行,但後來我無法發送推文。

回答

3

This hopefully已解決,我昨天剛剛上傳的版本。如果您尚未使用ROAuth的0.9.1版本,是否可以更新軟件包並重試?

+1

我實際上在Windows上,它看起來像最新版本的Windows二進制文件是0.9.0。 – 2012-02-21 17:55:48

+1

給它幾天,Win&Mac版本需要一段時間才能趕上CRAN - 不同的人管理這些存儲庫。 – geoffjentry 2012-02-21 18:27:23

+0

謝謝,我會在幾天內查看它是否已更新。 – 2012-02-21 19:07:42

2

我剛剛更新twitteRROAuth包就跑這些命令,一切都爲我工作:

cred = getTwitterOAuth(consumerKey, consumerSecret) 
registerTwitterOAuth(cred) 
tweet("something incredibly interesting...") 

似乎twitterR現在提供了一個簡潔的界面註冊OAuth的憑證,不需要明確使用呼叫OAuthFactory$newhandshake。當我試圖明確調用這些函數時,事情就開始破裂。但是當我使用上面的界面時,一切都很順利。

+0

嘗試了建議的代碼。執行「registerTwitterOauth」命令後收到以下錯誤:子字符串中的錯誤(digest,(1:hashlength)* 2 - 1,(1:hashlength)* 2):無法打開文件'C:/R/R-2.15。 2 /庫/消化/ R /摘要。rdb':沒有這樣的文件或目錄 – user2433346 2013-05-30 16:54:31

+0

@ user2433346不確定;我的測試是使用R 3.0的OS X 10.6.8 – 2013-05-30 17:55:13