From c8dc23e462fd55707c5a6ecc67e7f9b7020407a6 Mon Sep 17 00:00:00 2001 From: mburtonkelly Date: Thu, 1 Nov 2018 11:16:01 -0500 Subject: [PATCH] Set up .ini file for auth keys. --- auth.ini | 5 +++++ bin/gfk-publicstuff.R | 14 +++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 auth.ini diff --git a/auth.ini b/auth.ini new file mode 100644 index 0000000..5e317c3 --- /dev/null +++ b/auth.ini @@ -0,0 +1,5 @@ +[twitter] +consumer_key = +access_token = +consumer_secret = +access_secret = \ No newline at end of file diff --git a/bin/gfk-publicstuff.R b/bin/gfk-publicstuff.R index 2934d22..605179d 100644 --- a/bin/gfk-publicstuff.R +++ b/bin/gfk-publicstuff.R @@ -7,6 +7,7 @@ library(jsonlite) library(rjson) library(dplyr) library(twitteR) +library(ini) # Grab city view for Grand Forks gfk <- rjson::fromJSON(file="https://www.publicstuff.com/api/2.1/city_view?space_id=15174") @@ -43,11 +44,14 @@ gfk_requests <- bind_rows(gfk_requests) #### Tweeting # https://rcrastinate.blogspot.com/2018/05/send-tweets-from-r-very-short.html -# Need to create an external file with keys so they don't end up on GitHub -setup_twitter_oauth(consumer_key = "", - access_token = "", - consumer_secret = "", - access_secret = "") +# Read authentication values from ini file +# Don't commit real values to git! +auth <- read.ini("auth.ini") + +setup_twitter_oauth(consumer_key = auth$twitter$consumer_key, + access_token = auth$twitter$access_token, + consumer_secret = auth$twitter$consumer_secret, + access_secret = auth$twitter$access_secret) # After tweeting, write a small text file that has the last timestamp that was tweeted. Use that for grabbing future requests.