Git Product home page Git Product logo

Comments (29)

akinsbola452000 avatar akinsbola452000 commented on June 2, 2024 3

Thanks guys. I got same issue resolved by following the instructions on this forum. I simply added all the required library and followed the advice from @ddten to regenerate the all the keys. Now i'm working perfectly.

from twitter.

gallard28 avatar gallard28 commented on June 2, 2024 1

I had this problem when I went to scrape tweets. I solved it by opening libraries for "httpuv" and "openssl".

Session Info:
R version 3.4.1 (2017-06-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.2

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets
[6] methods base

other attached packages:
[1] dplyr_0.7.4 stringr_1.2.0 tm_0.7-3
[4] NLP_0.1-11 wordcloud_2.5 RColorBrewer_1.1-2
[7] SnowballC_0.5.1 httpuv_1.3.5 openssl_0.9.9
[10] twitteR_1.1.9

loaded via a namespace (and not attached):
[1] Rcpp_0.12.14 bindr_0.1 xml2_1.1.1
[4] magrittr_1.5 bit_1.1-12 lattice_0.20-35
[7] rjson_0.2.15 R6_2.2.2 rlang_0.1.6
[10] httr_1.3.1 tools_3.4.1 parallel_3.4.1
[13] grid_3.4.1 DBI_0.7 assertthat_0.2.0
[16] yaml_2.1.14 bit64_0.9-7 tibble_1.3.4
[19] bindrcpp_0.2 Matrix_1.2-12 curl_2.8.1
[22] glue_1.2.0 slam_0.1-42 stringi_1.1.5
[25] compiler_3.4.1 pkgconfig_2.0.1

Code below:

#Load Libraries
library("twitteR")
library("openssl")
library("httpuv")

library("twitteR")
library("tm")
library("stringr")
library("dplyr")

#Save your Twitter account Keys and Tokens. If you do not have a twitter account. https://apps.twitter.com/

consumer_key<-"code"
consumer_secret<-"code"
access_token <- "code"
access_secret <- "code"

#Connects you to Twitter
setup_twitter_oauth(consumer_key, consumer_secret, access_token , access_secret)
origop <- options("httr_oauth_cache")
options(httr_oauth_cache = TRUE)

#ChancellorDav Tweets
CD_Timeline <- userTimeline(user = "ChancellorDav", n = 3200, includeRts = FALSE, excludeReplies = TRUE)
toSpace <- content_transformer(function (x , pattern ) gsub(pattern, " ", x))

#Sapply Approach
CD_tweets <- sapply(CD_Timeline, function(x) { strsplit(gsub("[^[:alnum:] ]", "", x$text), " +")[[1]] })

#Overview of Data Scraped
head(CD_tweets)
tail(CD_tweets)
str(CD_tweets)

from twitter.

mayankvik2 avatar mayankvik2 commented on June 2, 2024 1

from twitter.

ddten avatar ddten commented on June 2, 2024 1

Have you both @monitotier @mayankvik2 tried to set the working directory? Like if you make a new folder on desktop named say R Studio then set the working directory as that?
Also regenerate all the keys.
Try writing the code like I did
library("openssl")
library("httpuv")
library("twitteR")
library("tm")
library("stringr")
library("dplyr")

api_key <- " code"
api_secret <- "code"
access_token <- "code"
access_secret <- "code"

setup_twitter_oauth(api_key,api_secret,access_token,access_secret)
origop <- options("httr_oauth_cache")
options(httr_oauth_cache = TRUE)
Also if you have problems with twitteR you can use rtweet.

from twitter.

mikkelkrogsholm avatar mikkelkrogsholm commented on June 2, 2024

I get the same error

from twitter.

jakeander avatar jakeander commented on June 2, 2024

Same here.

from twitter.

lgheorma avatar lgheorma commented on June 2, 2024

I've tried the following: adding the old version of the httr package, turning my firewall off, adding the base64enc package and nothing worked... And yes, I have installed all the packages AND I used the library function before trying to use them.
I don't know what else to do. I have Windows 8.1 and the most up to date versions of R, R studio, and of the packages.

Here is my code

library("base64enc")
library("twitteR")
library("ROAuth")
library("devtools")
library("memoise")
library("whisker")
library("rstudioapi")
library("git2r")
library("withr")
library("rjson")
library("bit64")
library ("httr")
library ("httpuv")

download.file(url="http://curl.haxx.se/ca/cacert.pem",destfile="cacert.pem")
consumerKey <- "key"
consumerSecret <- "key"
accessToken <- "key"
accessTokenSecret <- "key"

setup_twitter_oauth(consumerKey, consumerSecret, accessToken, accessTokenSecret)

*key= for each line I added the corresponding key from my Twitter App page.

from twitter.

dhelly avatar dhelly commented on June 2, 2024

This library resolve my problem.
library("openssl")
library("httpuv")

from twitter.

nadeemkhan786 avatar nadeemkhan786 commented on June 2, 2024

when i run code OTP get generated but when i use "search" command error can be generated

library(twitteR)
library(ROAuth)
#ibrary("openssl")
#ibrary("httpuv")
#library(base64enc)
consumer_key <- "code"
consumer_secret <- "code"
access_token <- "code"
access_secret <- "code"

#setup_twitter_oauth(consumer_key,consumer_secret,access_token,access_secret)

download.file(url="http://curl.haxx.se/ca/cacert.pem",destfile="cacert.pem")

setup_twitter_oauth(consumer_key,consumer_secret,access_token,access_secret)

tcred <- OAuthFactory$new(consumerKey=consumer_key,
consumerSecret=consumer_secret,
requestURL='https://api.twitter.com/oauth/request_token',
accessURL='https://api.twitter.com/oauth/access_token',
authURL='https://api.twitter.com/oauth/authorize')

tcred$handshake(cainfo="cacert.pem")

Error in twInterfaceObj$doAPICall(cmd, params, "GET", ...) :
OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()'

version 3.4.3 please help me

from twitter.

BroVic avatar BroVic commented on June 2, 2024

@nadeemkhan786 I get this error when I have poor internet. But you could fix the typos in your code so we're certain that we're on the same page....

from twitter.

nadeemkhan786 avatar nadeemkhan786 commented on June 2, 2024

@BroVic but i have good internet still i am in same place (error)

from twitter.

Bawage avatar Bawage commented on June 2, 2024

I am getting following error. Can anybody guide me?

Error in twInterfaceObj$doAPICall(cmd, params, "GET", ...) :
OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()'

from twitter.

luizot avatar luizot commented on June 2, 2024

Please, how to correct this error?

library(twitteR)
library(ROAuth)
library(RCurl) Carregando pacotes exigidos: bitops
library(openssl)
library(httpuv)
library(base64enc)
library(httr)
options(httr_oauth_cache=T)
setup_twitter_oauth(consumer_key,consumer_secret,access_token,access_secret)
[1] "Using direct authentication"
Error in check_twitter_oauth() : OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()'

from twitter.

ddten avatar ddten commented on June 2, 2024

I wrote a code like this and got an error as below:
library(httr)
options(httr_oauth_cache=T)
library(devtools)
library(twitteR)
library(base64enc)
library(ROAuth)
library(plyr)
library(dplyr)
library(stringr)
library(RCurl)
library(httpuv)
library(openssl)
library(ggplot2)
consumer_key<-"code"
consumer_secret<-"code"
access_token<-"code"
access_secret<-"code"
setup_twitter_oauth(consumer_key,consumer_secret,access_token,access_secret)
[1] "Using direct authentication"
Error in check_twitter_oauth() : OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()'
Can somebody help?

from twitter.

mayankvik2 avatar mayankvik2 commented on June 2, 2024

Thanks a lot. Using library openssl and httpuv resolved my Error in check_twitter_oauth() : OAuth authentication error. I was getting worried and in the end of two days I read this post and nailed the error out of my program. Once again thanks!!!

from twitter.

ddten avatar ddten commented on June 2, 2024

Share your code please @mayankvik2

from twitter.

nadeemkhan786 avatar nadeemkhan786 commented on June 2, 2024

check working directory

from twitter.

ddten avatar ddten commented on June 2, 2024

library("twitteR")
library("openssl")
library("httpuv")
library("twitteR")
library("tm")
library("stringr")
library("dplyr")

api_key <- " code"
api_secret <- "code"
access_token <- "code"
access_secret <- "code"

setup_twitter_oauth(api_key,api_secret,access_token,access_secret)
origop <- options("httr_oauth_cache")
options(httr_oauth_cache = TRUE)
I saved my code in desktop and set it as working directory but still the errors of check twitter oauth came.

from twitter.

jack-81 avatar jack-81 commented on June 2, 2024

Tried all the posted solutions but still face the same error:
[1] "Using direct authentication"
Error in check_twitter_oauth() : OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()'

Please anyone help to resolve this weird problem. I'm trying for a week to solve this and checked almost all the related forums around the Web. Here is my last place to ask or I will uninstall R and start another language!

from twitter.

ddten avatar ddten commented on June 2, 2024

from twitter.

jack-81 avatar jack-81 commented on June 2, 2024

I think this is an important issue that has many solutions. Do you think setting a bounty on bountify can be helpful.

I really need to solve this for an important project.

from twitter.

monitotier avatar monitotier commented on June 2, 2024

I exactly have the same issue, I have tried everything! it is so frustrating, Let me know if you solve it and how did you do it. I am still working on it too.

from twitter.

monitotier avatar monitotier commented on June 2, 2024

@ddten: Thanks for your quick response. After going through more threads I found that this package was missing "base64enc". It helped!
Thanks 😃

from twitter.

jack-81 avatar jack-81 commented on June 2, 2024

from twitter.

mad-moon avatar mad-moon commented on June 2, 2024

I found the solution in a Stackoverflow post. try to run setup_twitter_oauth(consumer_key, consumer_secret) and see what libraries are missing then install them.

from twitter.

GeekSnuff avatar GeekSnuff commented on June 2, 2024

Thanks akinsbola452000
I wasn't regenerating the keys!
phew...

from twitter.

PankajVerma123 avatar PankajVerma123 commented on June 2, 2024

during handshake with twitter i get error :-
Error in setup_twitter_oauth(consumer_key = consumerKey, consumer_secret = consumerSecret, :
could not find function "setup_twitter_oauth. please suggest me solution to this issue.
this is my rstudio code and i am using R 3.5.1

setting working directory

library(twitteR)
library(ROAuth)
library(plyr)
library(dplyr)
library(stringr)
library(ggplot2)
library(httr)
library(wordcloud)
library(SentimentAnalysis)
library(sentimentr)
library(RCurl)
library(openssl)
library(httpuv)
library(base64enc)
library(devtools)

oauth_endpoint(authorize = "https://api.twitter.com/oauth",
access = "https://api.twitter.com/oauth/access_token")

#connect to API
download.file(url ='http://curl.haxx.se/ca/cacert.pem', destfile ='cacert.pem')
reqURL <- 'https://api.twitter.com/oauth/request_token'
accessURL <- 'https://api.twitter.com/oauth/access_token'
authURL <- 'https://api.twitter.com/oauth/authorize'

Twitter Application

consumerKey="3GcJah1mIIDPD6c4uIW08L8YU"
consumerSecret="uevNdolvKfdCcG779UpiiD2wHTmP86kAUMqH7I9cjRuA3iJ35r"
accesstoken="869394410-vZb0G5EjJVF9STyLvVDotknPchwhcZ63zftWYyJe"
accesssecret="Ea3kWs4UCTqdNrWA76Wzall5MV2xRorrwlE8DYsc4ul5w"

cred <- OAuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret,
requestURL=reqURL,
accessURL=accessURL,
authURL=authURL)
cred$handshake(cainfo = system.file('CurlSSL', 'cacert.pem', package = 'RCurl'))

There is URL in console. You need to go to it, get code and enter it on console

Authorization PIN ~DYNAMIC

save(cred, file='twitter authentication.Rdata')

load('twitter authentication.Rdata')

Once you launch the code first time, you can start from this in the future(libraries should be connected)

setup_twitter_oauth(consumer_key = consumerKey,consumer_secret = consumerSecret,
access_token = accesstoken,access_secret = accesssecret)

###*******Step 3: Performs tweets extraction and data cleaning

Harvest some tweets

some_tweets = searchTwitter("statue of unity", n=5000, since = "2017-01-01", lang="en")

some_tweets = searchTwitter("Sardar Vallab Bhai Patel",n=5000, since = "2017-01-01", lang = "en")

(n.some_tweets <- length(some_tweets))

some_tweets.df <- ldply(some_tweets, function(t) t$toDataFrame())
write.csv(some_tweets.df,"tweets.csv")

get the text

some_txt = sapply(some_tweets, function(x) x$getText())

#remove request entities
some_txt = gsub("(RT/via)((?:\b\w*@\w+)+)","", some_txt)
#remove at people
some_txt = gsub("@\w+", "", some_txt)
#remove punctuation
some_txt = gsub("[[:punct:]]", "", some_txt)
#remove numbers
some_txt = gsub("[[:digit:]]","", some_txt)

remove html links

some_txt = gsub("http\w+","", some_txt)

remove unnecessary spaces

some_txt = gsub("[\t]{2,}","", some_txt)
some_txt = gsub("^\s+|\s+$","", some_txt)

define "tolower error handling" function

try.error = function(x)
{
#creating missing values
y = NA
#try catch error
try_error = tryCatch(tolower(x), error=function(e) e)

if not an error

if (!inherits(try_error, "error"))
y = tolower(x)

result

return(y)
}

#Tower case using try.error with sapply
some_txt = sapply(some_txt, try.error)

remove NAS in some_txt

some_txt = some_txt[!is.na(some_txt)]
names(some_txt) = NULL

}

from twitter.

nadeemkhan786 avatar nadeemkhan786 commented on June 2, 2024

from twitter.

PankajVerma123 avatar PankajVerma123 commented on June 2, 2024

anyone please help me find the issue with my code . i didn't get solution to this problem till yet, so please help me or send me r code to extract tweet that will be working in R 3.5.1.

  • i found this problem many time with different code
    Error in setup_twitter_oauth(consumer_key = consumerKey, consumer_secret = consumerSecret, :
    could not find function "setup_twitter_oauth. please suggest me solution to this issue.
    this is my rstudio code and i am using R 3.5.1

from twitter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.