2

I used R's packages 'twitteR' and 'ROAuth' to access Twitter API. I tried this R code to register my R session:

tw<-OAuthFactory$new(consumerKey="mykeyhere",consumerSecret="mysecrethere",  
requestURL="http://api.twitter.com/oauth/request_token",
accessURL="http://api.twitter.com/oauth/access_token",
authURL="http://api.twitter.com/oauth/authorize")
tw<-handshake()

I used http instead of https because the latter gave me an error of SSL certification fail. Then, I enter a PIN code obtained from a given URL and registered with Twitter:

registerTwitterOAuth(tw)

The result of the above command was:

[1] TRUE

I think that I successfully registered using OAuth. However, when I tried to access protected users' profiles, for example,

getURL("http://api.twitter.com/1/followers/ids.json?cursor=-1&user_id=XXXXXXXX")

I got this:

[1] "{\"error\":\"Not authorized\",\"request\":\"\\/1\\/followers\\/ids.json?cursor=-1&user_id=XXXXXXXX\"}"

I also checked my verification by using:

getURL("http://api.twitter.com/1/account/verify_credentials.json")

And this was the result:

[1] "{\"error\":\"Could not authenticate you.\",\"request\":\"\\/1\\/account\\/verify_credentials.json\"}"

Would you mind helping me please? Thank you very much.

Nama Keru
  • 911
  • 1
  • 7
  • 10
  • Did you try to make a post to your twitter account using this? If so what was the result? – Kevin Feb 14 '12 at 04:11

1 Answers1

2

You should use getUser(...),searchTwitter(...),tw$OAuthRequest(...) and so on instead of directly use getURL(...) by yourself because getURL() does not contain session context (which register using registerTwitterOAuth).

example of tw$OAuthRequest http://goo.gl/6IwdU