-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented reddit thread collection and actor network creation (#3)
* Added graph attribute for reddit * Refactored reddit create network and updated package documentation * Reimplemented reddit collection without oauth (future version) * Added reddit Create function graph attributes and types * Updated reddit function and parameter names * Updated minimum package versions for imports
- Loading branch information
Showing
25 changed files
with
620 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,4 @@ cred.R | |
*.rds | ||
*.csv | ||
*.graphml | ||
.Rproj.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
Package: vosonSML | ||
Version: 0.23.5 | ||
Date: 2018-11-01 | ||
Version: 0.24.0 | ||
Title: Tools for Collecting Social Media Data and Generating Networks for Analysis | ||
Description: A suite of tools for collecting and constructing networks from social media data. Provides easy-to-use functions for collecting data across popular platforms (Instagram, Facebook, Twitter, and YouTube) and generating different types of networks for analysis. | ||
Description: A suite of tools for collecting and constructing networks from social media data. | ||
Provides easy-to-use functions for collecting data across popular platforms (Instagram, | ||
Facebook, Twitter, YouTube and Reddit) and generating different types of networks for analysis. | ||
Type: Package | ||
Imports: tm, stringr, twitteR, RCurl, bitops, rjson, plyr, igraph, Rfacebook (>= 0.6.15), Hmisc, data.table, httpuv, instaR, methods, httr | ||
Suggests: magrittr, testthat | ||
Author: Timothy Graham & Robert Ackland with contributions from Bryan Gertzel & Chung-hong Chan | ||
Imports: tm, stringr, twitteR, RCurl, bitops, rjson, plyr, igraph (>= 1.2.2), Rfacebook (>= 0.6.15), | ||
Hmisc, data.table, httpuv, instaR, methods, httr, RedditExtractoR (>= 2.1.2), magrittr, | ||
dplyr (>= 0.7.8), rlang (>= 0.3.0.1) | ||
Depends: R (>= 3.2.0) | ||
Suggests: testthat | ||
Encoding: UTF-8 | ||
Author: Timothy Graham, Robert Ackland, Chung-hong Chan, Bryan Gertzel | ||
Maintainer: Bryan Gertzel <[email protected]> | ||
License: GPL (>= 2) | ||
RoxygenNote: 6.1.0 | ||
RoxygenNote: 6.1.1 | ||
NeedsCompilation: no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#' Reddit API authentication. | ||
#' | ||
#' OAuth2 based authentication with the Reddit API that returns an authentication token. | ||
#' | ||
#' The httr package has a known OAuth2 issue with its parameter "use_basic_auth", The default value is set to FALSE | ||
#' and is missing parameter pass through meaning it can not be set to TRUE as required by reddit oauth2 authentication. | ||
#' The point patch devtools::install_github("r-lib/httr#485") fixes this issue. | ||
#' Further information: https://github.com/r-lib/httr/issues/482 | ||
#' | ||
#' Reddit oauth tokens are only valid for one hour and using cached token will subsequently produce 401 errors. | ||
#' | ||
#' @param appName character string containing the reddit app name associated with the API key. | ||
#' @param appKey character string containing the app key. | ||
#' @param appSecret character string containing the app secret. | ||
#' @param useTokenCache logical. Use cached authentication token if found. | ||
#' | ||
#' @return a reddit authentication token | ||
#' | ||
AuthenticateWithRedditAPI <- function(appName, appKey, appSecret, useTokenCache) { | ||
|
||
if (missing(appName)) { | ||
appName <- "reddit" | ||
} | ||
|
||
if (missing(appKey) | missing(appSecret)) { | ||
cat("Error. One or more API credentials are missing.\nPlease specify these.\n") | ||
return() | ||
} | ||
|
||
if (missing(useTokenCache)) { | ||
useTokenCache <- FALSE | ||
} | ||
|
||
# sets up oauth2 for reddit | ||
reddit_endpoint <- httr::oauth_endpoint( | ||
authorize = "https://www.reddit.com/api/v1/authorize", | ||
access = "https://www.reddit.com/api/v1/access_token" | ||
) | ||
|
||
reddit_app <- httr::oauth_app(appName, key = appKey, secret = appSecret) | ||
|
||
reddit_token <- httr::oauth2.0_token(reddit_endpoint, reddit_app, | ||
user_params = list(duration = "permanent"), | ||
scope = c("read"), | ||
use_basic_auth = TRUE, | ||
config_init = user_agent("httr oauth"), | ||
cache = useTokenCache) | ||
|
||
return(reddit_token) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#' YouTube API Authentication | ||
#' | ||
#' OAuth based authentication with the Google API. | ||
#' | ||
#' In order to collect data from YouTube, the user must first authenticate with Google's Application Programming | ||
#' Interface (API). Users can obtain a Google Developer API key at: https://console.developers.google.com. | ||
#' | ||
#' @param apiKeyYoutube character string specifying your Google Developer API key. | ||
#' | ||
#' @return This is called for its side effect. | ||
#' | ||
#' @note In the future this function will enable users to save the API key in working directory, and the function will | ||
#' automatically look for a locally stored key whenever it is called without apiKeyYoutube argument. | ||
#' | ||
#' @noRd | ||
authenticateWithYoutubeAPI <- function(apiKeyYoutube) { | ||
return(apiKeyYoutube) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.