Git Product home page Git Product logo

twitter's Introduction

DEPRECATION

This is the start of a relatively leisurely deprecation period for twitteR, in favor of using rtweet. Please start looking to switch over to that package. If you have any questions contact myself or @mkearney

twitteR

twitteR is an R package which provides access to the Twitter API. Most functionality of the API is supported, with a bias towards API calls that are more useful in data analysis as opposed to daily interaction.

Getting Started

  • Please read the user vignette, which admittedly can get a bit out of date
  • Create a Twitter application at http://dev.twitter.com. Make sure to give the app read, write and direct message authority.
  • Take note of the following values from the Twitter app page: "API key", "API secret", "Access token", and "Access token secret".
  • You can use the CRAN version (stable) via the standard install.packages("twitteR") or use the github version. To do the latter:
    • install.packages(c("devtools", "rjson", "bit64", "httr"))
    • Make sure to restart your R session at this point
    • library(devtools)
    • install_github("geoffjentry/twitteR")
  • At this point you should have twitteR installed and can proceed:
    • library(twitteR)
    • setup_twitter_oauth("API key", "API secret")
      • The API key and API secret are from the Twitter app page above. This will lead you through httr's OAuth authentication process. I recommend you look at the man page for Token in httr for an explanation of how it handles caching.
    • You should be ready to go!
  • If you have any questions or issues, check out the mailing list

twitter's People

Contributors

abicky avatar aloth avatar apatil avatar bbrewington avatar chlorenz avatar christopherhackett avatar dmedri avatar geoffjentry avatar jlegewie avatar joelgombin avatar jonocarroll avatar jrowen avatar kevinbrosnan avatar lmmx avatar pkq avatar pnulty avatar seanchrismurphy avatar sinhrks avatar smschauhan avatar superman32432432 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twitter's Issues

Provide for a DB backend for searches

I know of many people who have some homebrew mechanism for storing their searches in a database. Provide a standardized mechanism for doing this with a generic backend to support different types of DBs. Initially provide SQLite and MySQL.

client error: (401) Unauthorized

While trying to use twitteR interactively in R Studio I got this error... "XXXXXX's" are my key and secret respectively.

library(twitteR)
setup_twitter_oauth("XXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
[1] "Using browser based authentication"
Use a local file to cache OAuth access credentials between R sessions?
1: Yes
2: No

Selection: 1
Error in init_oauth1.0(endpoint, app, permission = params$permission) :
client error: (401) Unauthorized

I would appreciate any help. I have also seen the same question on stackoverflow but no answer was given. I am running R 3.1.1 with httr 0.5.0.90 and twitteR version 1.1.8.

Thanks,

B

List of Followers

Hey Geoff,

Im a R novice so excuse my general ignorance. Im trying to get a list of followers for a particular twitter user. The code here is not working for me. Im getting error code "could not find function ffbase". Say Im trying to download a list of Barack Obama's followers. How could I do that?

Also - Is it possible to get a list of geo-located followers?

thanks x 1 mil!!

Unable to run publicTimeline() Error: Not Found

I complete a successful OAuth handshake, and most functions of twitteR seem to work fine, except publicTimeline():

registerTwitterOAuth(twitCred)
[1] TRUE

public_tweets = publicTimeline()
Error: Not Found

sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

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 methods base

other attached packages:
[1] ROAuth_0.9.2 digest_0.6.2 twitteR_0.99.19 rjson_0.2.12 RCurl_1.95-3 bitops_1.0-4.2

loaded via a namespace (and not attached):
[1] tools_2.15.2

How to retrieve multiple tweets from tweet_id using R

I am using the twitteR package in R to extract tweets based on their ids. But I am unable to do this for multiple tweet ids without hitting either a rate limit or an error 404. This is because I am using the showStatus() - one tweet id at a time. I am looking for a function similar to getStatuses() - multiple tweet id/request

Is there an efficient way to perform this action. I suppose only 60 requests can be made in a 15 minute window using the outh.

So, how do I ensure :-
1.Retrieve multiple tweet ids for single request thereafter repeating these requests.
2.Rate limit is under check.
3.Error handling for tweets not found.

P.S : This activity is not user based.

Thanks

tolower suggestion

Hi there,

I've been looking for a solution to lower the case of tweets and clean up the data before doing any analysis. Here is a small but useful finding that makes the tolower() function work with no need to do anything else.

I've been using the clean.text function provided here(https://sites.google.com/site/miningtwitter/) quite a bit. But as it normally is, the tolower(x) doesn't always work. I've seen in Jeffrey breen's page a coment regarding this, and i thought of sharing it here. I think it deals well with the lowering-case issue.

The solution is just to add this x = iconv(x, 'UTF-8', 'ASCII') before the tolower() statement. I've added it below already.

Doing it this way, you won't need to use the tryTolower function (you can find this in the same page). It's just changing the enconding before.

I think this is useful for sentiment analysis also, if you can't lower the case of all the words it's hard to get a good result.

Hope you find it useful!

clean.text = function(x)
{

tolower

x = iconv(x, 'UTF-8', 'ASCII')
x = tolower(x)

remove rt

x = gsub("rt", "", x)

remove at

x = gsub("@\w+", "", x)

remove punctuation

x = gsub("[[:punct:]]", "", x)

remove numbers

x = gsub("[[:digit:]]", "", x)

remove links http

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

remove tabs

x = gsub("[ |\t]{2,}", "", x)

remove blank spaces at the beginning

x = gsub("^ ", "", x)

remove blank spaces at the end

x = gsub(" $", "", x)
return(x)
}

Unable to run homeTimeline() after authenticating

I run the authentication steps successfully:

library(ROAuth)
library(twitteR)

reqURL = "https://api.twitter.com/oauth/request_token"
accessURL = "http://api.twitter.com/oauth/access_token"
authURL = "http://api.twitter.com/oauth/authorize"
consumerKey = "Hidden"
consumerSecret = "Hidden"
twitCred <- OAuthFactory$new(consumerKey=consumerKey,
                             consumerSecret=consumerSecret,
                             requestURL=reqURL,
                             accessURL=accessURL,
                             authURL=authURL)

twitCred$handshake() ## Authenticate in browser

And then on running homeTimeline() I get this error with this trackback:

> homeTimeline()
Error in function (str)  : 
  promise already under evaluation: recursive default argument reference or earlier problems?

Enter a frame number, or 0 to exit   

 1: homeTimeline()
 2: authStatusBase(n, "home_timeline", maxID = maxID, sinceID = sinceID, ...)
 3: statusBase(cmd, params, n, 800, ...)
 4: sapply(doPagedAPICall(cmd, n, params, ...), buildStatus)
 5: lapply(X = X, FUN = FUN, ...)
 6: doPagedAPICall(cmd, n, params, ...)
 7: twInterfaceObj$doAPICall(cmd, params, method, ...)
 8: APIFunc(url, params, method, ...)
 9: oauth$OAuthRequest(url, params, method, ...)
10: httpFunc(URLencode(URL), params = params, consumerKey = .self$consumerKey, 
11: getForm(url, .params = params, curl = curl, .opts = .opts, binary = binary)
12: getURLContent(uri, .opts = .opts, .encoding = .encoding, binary = binary, c
13: curlPerform(url = url, curl = curl, .opts = .opts)
14: function (str) 
{
    if (verbose) 
        cat("inBody? ", inBody, ", num byt

Selection: 

Here's my sessionInfo()

R version 2.15.1 (2012-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=C                  LC_COLLATE=C              
 [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=C                 LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] twitteR_0.99.19 rjson_0.2.8     ROAuth_0.92.0   digest_0.5.2   
[5] RCurl_1.91-1    bitops_1.0-4.1  knitr_0.6.5     devtools_0.7.1 

loaded via a namespace (and not attached):
[1] Rcpp_0.9.10    evaluate_0.4.2 formatR_0.4    httr_0.1.1     memoise_0.1   
[6] parser_0.0-14  plyr_1.7.1     stringr_0.6    tools_2.15.1  

Any ideas? Thanks!

Master version installation

Thank you again for the development of the package.
Adding support for profiles photo was nice.
I see that recent versions handle an issue about sinceID; howver I am not able to test as installation from Github laster has a dependancy towards "ROAuth 0.9.4" not available, neither on CRAN nor there.
Eric

(403) Forbidden while updating status

Hi,

I simply register my OAuth with:

setup_twitter_oauth(api_key,api_secret,access_token,access_token_secret)

And later I try to update my status via updateStatus('Blah blah blah'). For the first run I can do this but later for some hours I cannot again do this and receive this message:

Error in twInterfaceObj$doAPICall(endpoint, params = params, method = "POST", :
client error: (403) Forbidden

Can anyone help me?

ERROR: dependency 'int64' is not available for package 'twitteR'

devtools::install_github("twitteR", username="geoffjentry")
Installing github repo twitteR/master from geoffjentry
Downloading twitteR.zip from https://github.com/geoffjentry/twitteR/archive/master.zip
Installing package from /tmp/RtmpAf0RDJ/twitteR.zip
arguments 'minimized' and 'invisible' are for Windows only
Installing twitteR
Installing dependencies for twitteR:
httr, int64
Installing packages into ‘/home/hadoop/R/x86_64-suse-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
пробую URL 'http://cran.rstudio.com/src/contrib/httr_0.2.tar.gz'
Content type 'application/x-gzip' length 50183 bytes (49 Kb)
открытие URL
downloaded 49 Kb

  • installing source package ‘httr’ ...
    ** пакет ‘httr’ удачно распакован, MD5 sums проверены
    ** R
    ** demo
    ** inst
    ** preparing package for lazy loading
    ** help
    *** installing help indices
    ** building package indices
    ** testing if installed package can be loaded
  • DONE (httr)
    The downloaded source packages are in
    ‘/tmp/RtmpAf0RDJ/downloaded_packages’
    '/usr/lib64/R/bin/R' --vanilla CMD INSTALL
    '/tmp/RtmpAf0RDJ/devtoolsf9f5ed1b0a3/twitteR-master'
    --library='/home/hadoop/R/x86_64-suse-linux-gnu-library/3.0' --install-tests
    ERROR: dependency 'int64' is not available for package 'twitteR'
  • removing '/home/hadoop/R/x86_64-suse-linux-gnu-library/3.0/twitteR'
    Ошибка: Command failed (1)
    Вдобавок: Предупреждение
    package ‘int64’ is not available (for R version 3.0.2)

setup_twitter_oauth documentation missing

using the function registerTwitterOAuth(Cred)

produces the error:

Error in registerTwitterOAuth(Cred) :
ROAuth is no longer used in favor of httr, please see ?setup_twitter_oauth

but no such documentation exists

BlockOnRateLimit and limits

blockOnRateLimit need to be TRUE by default everywhere (with network calls), a nice feature that should be renamed for logical reasons. It's not a "block", more a "delayed get (client-side) that will restart in a couple of minutes" :)

One another idea: pass an object with pre-defined (and editable) twitter limits. More than technical issues, to document the existence of these limits and centralize these configurations.

decode url

Want to have the option to decode shortened URLs

Support time ranges

It would useful (to me at least) if searchTwitter supported time ranges. For example,

searchTwitter('#rstats', n = 100, since = "2014-05-24 12:54:24 UTC", until = "2014-05-24 23:54:24 UTC")

TwitterR - https and http

Hi Jeff:

I am using your TwitterR package (Thank you so much for your work on this!) and comes to a problem.

My PC sits behind a company Proxy and it got issue accessing web throught "https" connections.

Since Twitter API reuqires Oauth now and one of your function in the package "getAPIStr" used an "if else" statement, which if Oauth is TRUE it will use "https" instead of "http".

Is there anyway I can update this function to remove the "if else" statement and force it to use "http" all the time?

While I am on this, is there anyother functions in your package will create "https"?

Cheers!

exotic characters handling

It seems that when a status contains some "exotic" (non alphanumeric) character, the twitteR functions may not be able to handle them correctly (at least to the best of my understanding, which remains limited).

An example:
showStatus("439748835238510592")

returns

"AsapVoltaire: RT @CoralieDji: \"Tu penses quoi de Beyoncé ?\" \n\"Je pense que Dieudonné a sa place la dedans\" - @AsapVoltaire \xed\xa0\xbd\xed\xb8\x82\xed\xa0\xbd\xed\xb8\x82\xed\xa0\xbd\xed\xb8\x82"

Is there any way to postprocess this? (by the way I tried the forceUtf8Conversion=TRUE option, but it throws: Error in tw_from_response(out, ...) : unused argument (forceUtf8Conversion = TRUE))

If there's no way to fix this, I think we should at least filter this out, because then it throws errors with further treatments.

Error in check_twitter_oauth() : OAuth authentication error:

Hello everybody

i have this problem in my code

install.packages(c("devtools", "rjson", "bit64", "httr"))
devtools::install_github("hadley/httr")

RESTART R session!

library(devtools)
install_github("twitteR", username="geoffjentry")
library(twitteR)

api_key <- "mwcOI7mNkPUhRnnit0Nu75VBO"

api_secret <- "BwyN7OvghbPSW9RDSaSzVu0aRhhH2bKRvQcUucUZQYyxbKSW2u"

access_token <- "2829195264-D8HgRXZCyUd193lC5ILEFsxgGdgIldvBP8zo64E"

access_token_secret <- "2829195264-D8HgRXZCyUd193lC5ILEFsxgGdgIldvBP8zo64E"

setup_twitter_oauth(api_key,api_secret,access_token,access_token_secret)

and i get this error

Error in check_twitter_oauth() : OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()'

please can someone help me i reaaly need this problem solve pleasee

Support time ranges

It would useful (to me at least) if searchTwitter supported time ranges. For example,

searchTwitter('#rstats', n = 100, since = "2014-05-24 12:54:24", until = "2014-05-24 23:54:24")

showStatus doesn't get the specified status

showStatus requires a numeric argument, but R doesn't have 64 bit integer.
Therefore, showStatus can't deal with id which is greater than 2^53 correctly.
Currently, status IDs of Twitter are greater than 2^58.

I think showStatus should allow a character argument.

Split n in k parts to avoid Twitter limits

With retryOnRateLimit > 0 we've a new solution to "get" problems, but it's like doing the same mistake many times. With a "get" request you know the number n of entries requested and (usually) your limit (eg. 800).

IDEA:

Split n in k parts (to have so many n numbers below the limit) and run k "get" requests.
Every new k "get" request starts from latest ID (eg. status, user, follower, friend) AND latest datetime field.

showStatus function in TwitteR package returns error

Hi,
I am getting the following error while trying to run the showStatus function on twitter ID's in order to return the various attributes of the tweet such as text, creation date, user ID etc.
image

Note: The function runs and returns the desired output for 3-4 ID's before the error shown above pops up and the code stops executing.

What can be done to tackle the issue. I have installed the latest version of the package from github.

Cheers!

Error in split.default(users, ceiling(seq_along(users)/100))

Hi Geoff,

Absolutely love the package. I've just started working with R and this package has been a lot of fun.

I'm working on visualizing a friend network using:

    following <- seed$getFriends()
    following.n <- as.character(lapply(following, function(x) x$getScreenName()))

followed by a loop:

    > twitter.data <- list()
    > i <- 1
    > for (new.user in following.n){
            user <- getUser(new.user)
            friends <- user$getFriends(retryOnRateLimit=1000)
            twitter.data[[i]] <- as.character(lapply(friends, function(x) x$getScreenName()))
    }

However, every time i get the error:

    Error in split.default(users, ceiling(seq_along(users)/100)) : 
      first argument must be a vector

Is it an error in the package?

All the best, big fan!

Max

showStatus(id='123') doesn't work

Example in help page:

status-class {twitteR} R Documentation
Class to contain a Twitter status

Error:

showStatus(id='123')
[1] "missing value where TRUE/FALSE needed"
Error in twInterfaceObj$doAPICall(paste("statuses", "show", id, sep = "/"), :
Error: missing value where TRUE/FALSE needed

setup_twitter_oauth without error, recent id doesn't work either.

Thanks

Protected user profiles raise OAuth authentication error

calls to getFriendIDs() for a list of users kept crashing with error message:

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

crashes happened only at specific user id's.. upon further inspection, these specific users are protected ones (crashes have nothing to do with authentication). An easy workaround is to condition processing of user on protected status.

Expose rate limit information sent with each API reply

We make a lot of API requests and frequently hit the rate limit. In order to schedule our requests it would be very helpful to always know the number of remaining calls and when the limit resets. Fortunately, the Twitter API returns the remaining calls and the reset time in the header of each reply (x-rate-limit-remaining, x-rate-limit-reset).

Do you think that this information could be somehow exposed through twitteR?

If you are generally supportive of such a feature, I'd be happy to provide relevant patches.

Error: Deprecated: supply token object to config directly

Hello

I'm using last git version of twitteR package and I'm connecting on Twitter through setup_twitter_oauth() function. When I call the function

setup_twitter_oauth("XXX", "YY", "CCC", "VVXXXX", credentials_file="twitter.cred")

I get:

Error: Deprecated: supply token object to config directly

What's wrong? Older versions (of twitteR and maube other packages) work fine for me...

Thank
Matteo
http://www.redaelli.org/matteo/

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.