mkearney / tweetbotornot

🤖 R package for detecting Twitter bots via machine learning
https://tweetbotornot.mikewk.com
Other
388 stars 138 forks source link

Error reading from connection #20

Open ElenaCorriero opened 5 years ago

ElenaCorriero commented 5 years ago

I've downloaded the package and attempted to run it on a vector of usernames, but I get an error result:

Error in readRDS(x) : error reading from connection

mkearney commented 5 years ago

Can you include the code you used? This error is typically due to an incorrect path passed to readRDS(), which would have to be from either (a) when you read in your vector of screen names or (b) when rtweet tried to read your token.

W/o more code to replicate, my advice is to install the newest version of rtweet

## install newest version of rtweet
install.packages("rtweet")

Check to make sure it's at least version 0.6.8

packageVersion("rtweet")
[1] '0.6.8'

Then, to make sure rtweet gets configured correctly, wipe any TWITTER_PAT environment variables and do a quick search:

## wipe twitter_pat env var
Sys.setenv(TWITTER_PAT = "")

## search via rtweet
rt <- rtweet::search_tweets("lang:en")

That should pop-up a window asking you to authorize the rstats2twitter (rtweet) client, which will enable rtweet to send API requests on your behalf (which {{tweetbotornot}} uses to gather data it needs to generate estimate)

ElenaCorriero commented 5 years ago

Hi MIchael,

Thank you for responding!

It turns out I had not followed the right authentication process - I had set up a token for a different application and assumed it would work. After I set up the authentication for rtweet, I followed your instructions and the botornot command seemed to be running; however, I receive this error message:

Error in textfeatures::textfeatures(x, normalize = FALSE, word_dims = 0) : unused arguments (normalize = FALSE, word_dims = 0)

Here's my code:

library(tweetbotornot) library(rtweet)

packageVersion("rtweet")

consumer_key <- "pnQmvgyUKbmedb1OZhSv6xbih" consumer_secret <- "V7FNEkTSGKvMChgK4OqVms9r15Q7hrQDwDhu5OPQVnl5IhJL2r" access_token <- "911645742-jL1RAmUR5DkzWq3LK33iUAL5FtplY3eRN4p0dI1V" access_secret <- "tStF3lbCSoAdThH4mHXvwRk3U1cZjbX221GCKot351TMy"

token <- create_token( app = "my_twitter_research_app", consumer_key, consumer_secret, access_token, access_secret)

search via rtweet works!

rt <- rtweet::get_my_timeline(n=100) rt <- rtweet::search_tweets("GMO", n=100)

Test username for bot score

botornot("AlertTrade")

I did not try the command with the vector of usernames, but here's the syntax for that:

users <- as.vector(Neg$Author) users[1:5] #returns correctly the names as a vector

Thank you for helping on this, I'm really curious to run your test! By the way, is there a limit to the number of usernames that can be tested at once?

Elena

Il giorno gio 4 ott 2018 alle ore 17:16 Michael W. Kearney < notifications@github.com> ha scritto:

Can you include the code you used? This error is typically due to an incorrect path passed to readRDS(), which would have to be from either (a) when you read in your vector of screen names or (b) when rtweet https://github.com/mkearney/rtweet tried to read your token.

W/o more code to replicate, my advice is to install the newest version of rtweet

install newest version of rtweet

install.packages("rtweet")

Check to make sure it's at least version 0.6.8

packageVersion("rtweet") [1] '0.6.8'

Then, to make sure rtweet gets configured correctly, wipe any TWITTER_PAT environment variables and do a quick search:

wipe twitter_pat env var

Sys.setenv(TWITTER_PAT = "")

search via rtweetrt <- rtweet::search_tweets("lang:en")

That should pop-up a window asking you to authorize the rstats2twitter (rtweet) client, which will enable rtweet to send API requests on your behalf (which {{tweetbotornot}} uses to gather data it needs to generate estimate)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mkearney/tweetbotornot/issues/20#issuecomment-427172380, or mute the thread https://github.com/notifications/unsubscribe-auth/And07IuFlb3rdzlPQjNHaHrxxKbsUHa8ks5uhnrFgaJpZM4XIjNH .

sevetseh28 commented 5 years ago

Im getting the same error:

Error in textfeatures::textfeatures(x, normalize = FALSE, word_dims = 0) : unused arguments (normalize = FALSE, word_dims = 0)

Any idea @mkearney ?

sevetseh28 commented 5 years ago

btw im using 3.5.1 version of R

sevetseh28 commented 5 years ago

I will report this on another issue since it's another problem and seems to be recent.

Hawkeye407 commented 5 years ago

Hi, I have the same problem: tweetbotornot("realdonaldtrump") Error in readRDS(x) : error reading from connection

I thing this isn't problem with token. For userTimeline() function I have good results:

userTimeline("realdonaldtrump", n = 10) [[1]] [1] "realDonaldTrump: If Chuck Schumer and Nancy Pelosi gain the majority, they will try to raise your taxes, restore job-killing regulat… https://t.co/Oz37oGMsT6" ...

R version 3.5.1 (2018-07-02) -- "Feather Spray" Platform: x86_64-w64-mingw32/x64 (64-bit)

@mkearney

Hawkeye407 commented 5 years ago

Hi guys, today I solved the problem. I used different authorization which not work with this package. Before I used:

consumer_key <- "xxxxxxxxxxxxxxxxxxxx" consumer_secret <-"xxxxxxxxxxxxxxxxxx" access_token <-"xxxxxxxxxxxxxxxxx" access_secret <- "xxxxxxxxxxxxxx" setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret)

It's work for twitterR package.

But for tweetbotornot you must use:

if (!requireNamespace("httpuv", quietly = TRUE)) { install.packages("httpuv") } token <- create_token( app = "best_app_for_mining", consumer_key = "xxxxxxxxxxxxxxxxxxxx", consumer_secret = "xxxxxxxxxxxxxxxx")

identical(twitter_token, get_token())