Set up .ini file for auth keys.

This commit is contained in:
mburtonkelly
2018-11-01 11:16:01 -05:00
parent 7ae6d2c4d4
commit c8dc23e462
2 changed files with 14 additions and 5 deletions

5
auth.ini Normal file
View File

@ -0,0 +1,5 @@
[twitter]
consumer_key = <your Consumer Key>
access_token = <your Acces Token>
consumer_secret = <your Consumer Secret>
access_secret = <your Access Token Secret>

View File

@ -7,6 +7,7 @@ library(jsonlite)
library(rjson) library(rjson)
library(dplyr) library(dplyr)
library(twitteR) library(twitteR)
library(ini)
# Grab city view for Grand Forks # Grab city view for Grand Forks
gfk <- rjson::fromJSON(file="https://www.publicstuff.com/api/2.1/city_view?space_id=15174") 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 #### Tweeting
# https://rcrastinate.blogspot.com/2018/05/send-tweets-from-r-very-short.html # 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 # Read authentication values from ini file
setup_twitter_oauth(consumer_key = "<your Consumer Key>", # Don't commit real values to git!
access_token = "<your Acces Token>", auth <- read.ini("auth.ini")
consumer_secret = "<your Consumer Secret>",
access_secret = "<your Access Token Secret>") 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. # After tweeting, write a small text file that has the last timestamp that was tweeted. Use that for grabbing future requests.