Browse Source

Edit: some cleanup work

pull/2/head
jayvii 1 year ago
parent
commit
608c363c6d
1 changed files with 22 additions and 14 deletions
  1. 22
    14
      collecto.R

+ 22
- 14
collecto.R View File

@@ -12,8 +12,8 @@ library("twitteR")
# had to install "httr" via packagemanager

#### Facebook
install.packages("Rfacebook")
library("Rfacebook")
#install.packages("Rfacebook")
#library("Rfacebook")

#### Fediverse (eg: mastodon)
install.packages("devtools")
@@ -25,11 +25,13 @@ library("mastodon")
## Twitter Collector {{{ ----

### Authenticate to Twitter

#### Manual input (uncomment if needed)
#twitter_consumerkey <- readline("[Twitter] Enter your consumer API key.")
#twitter_consumerpri <- readline("[Twitter] Enter your consumer API secret.")
#twitter_tokenaccess <- readline("[Twitter] Enter your Access Token.")
#twitter_tokensecret <- readline("[Twitter] Enter your Token Secret.")

#### Saved credentials
twitter_api_cred <- read.table(file = "./twitter_api.txt", header = TRUE, sep = ";")
twitter_consumerkey <- as.character(twitter_api_cred$consumer_key)
@@ -144,13 +146,13 @@ retw <- as.factor(twitter_rts)
favs <- as.factor(twitter_fav)
link <- as.character(twitter_url)
text <- as.character(twitter_txt)
clit <- as.character(twitter_client)
clnt <- as.character(twitter_client)

### Creating dataframe
twitter <- data.frame(cbind(date, time, retw, favs, text, link, clit))
twitter <- data.frame(cbind(date, time, retw, favs, text, link, clnt))

#### Clean-Up
rm(list = c("date", "time", "retw", "favs", "text", "link", clit))
rm(list = c("date", "time", "retw", "favs", "text", "link", "clnt"))

twitter <- within(data = twitter, expr = {
date <- as.numeric(as.character(date));
@@ -162,23 +164,29 @@ twitter <- within(data = twitter, expr = {

## Facebook Collector [WIP] {{{ ----

# Note -------------------------------------------------------------------------
# I was not able to get API Keys for Facebook, thus this package is useless.
# I may look into HTML webscraping, if time allows for this
# ------------------------------------------------------------------------------

### Authenticate to Facebook
#### Manual input (uncomment if needed)
#facebook_app_id <- readline("[Twitter] Enter your App ID key.")
#facebook_secret <- readline("[Twitter] Enter your App Secret.")
#### Saved credentials
facebook_api_cred <- read.table(file = "./facebook_api.txt", header = TRUE, sep = ";")
facebook_app_id <- as.character(facebook_api_cred$app_id)
facebook_secret <- as.character(facebook_api_cred$app_secret)
#facebook_api_cred <- read.table(file = "./facebook_api.txt", header = TRUE, sep = ";")
#facebook_app_id <- as.character(facebook_api_cred$app_id)
#facebook_secret <- as.character(facebook_api_cred$app_secret)

facebook_auth <- fbOAuth(app_id = facebook_api_id,
app_secret = facebook_secret)
#facebook_auth <- fbOAuth(app_id = facebook_api_id,
# app_secret = facebook_secret)

### Get posts from FSFE
facebook_fsfe_posts <- Rfacebook::getPage(page = "thefsfe",
token = facebook_auth,
since = "2018-01-01",
until = "2018-31-12")
#facebook_fsfe_posts <- Rfacebook::getPage(page = "thefsfe",
# token = facebook_auth,
# since = "2018-01-01",
# until = "2018-31-12")

# }}}

## Mastodon Collector {{{ ----

Loading…
Cancel
Save