-
-
Save mjhea0/5497065 to your computer and use it in GitHub Desktop.
Create an app on https://dev.twitter.com/, make sure you leave Callback URL blank (so that it will return to a page where twitter shows you a PIN, useful during twitCred$handshake below. Don't worry yet, read on.) | |
Run these on R (on separate lines): | |
reqURL <- "https://api.twitter.com/oauth/request_token" | |
accessURL <- "http://api.twitter.com/oauth/access_token" | |
authURL <- "http://api.twitter.com/oauth/authorize" | |
consumerKey <- "yourconsumerkey" | |
consumerSecret <- "yourconsumersecret" | |
twitCred <- OAuthFactory$new(consumerKey=consumerKey,consumerSecret=consumerSecret,requestURL=reqURL,accessURL=accessURL,authURL=authURL) | |
download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile="cacert.pem") | |
twitCred$handshake(cainfo="cacert.pem") | |
registerTwitterOAuth(twitCred) | |
And make sure you specify the PEM cert when calling the searchTwitter method: | |
tweets = searchTwitter("#abortion", n=200, cainfo="cacert.pem") |
I updated my rstudio version and it started working.
Thanks!
Now the twitter authentication has been changed. Currently "setup_twitter_oauth(key,secret,key2,secret2)" is being used.
What changes to the existing code are to be made?
consumerKey<-"ConsumerKey"
consumerSecret<-"ConsumerSecret"
access_token_secret<-"AccessTocketSecret"
access_token<-"AccessToken"
setup_twitter_oauth(consumerKey,consumerSecret,access_token,access_token_secret)
Once your authentication is setup, you can start scrapping tweeter:
tweets= searchTwitter("#trend", n=1500)
can u give the java code
setup_twitter_oauth(consumer_key=consumerkey, consumer_secret=consumerSecret, access_token=accessToken, access_secret=accessSecret)
[1] "Using direct authentication"
Error in check_twitter_oauth() : OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()'
I get the above error message :(