Skip to content

functions for accessing the twilio API from within R

Notifications You must be signed in to change notification settings

workingamerica/twilio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

twilio

Functions for accessing the twilio API from within R

Installing

Generate a personal access token: https://github.com/settings/tokens

You need the 'repo' access levels assigned.

install.packages("remotes")
remotes::install_github(
  repo = 'workingamerica/twilio',
  auth_token = '' # personal access token here, between quote marks
)

library(twilio)

Permanently save twilio credentials as environment variables:

Run this:

usethis::edit_r_environ()

It'll open a file called .Renviron, which is saved in your home folder. (On Windows, this is of the form C:/Users/myusername/Documents/.Renviron.) Enter environment variables like so (no quotes), save, close, and restart R.

TWILIO_ACCOUNT_SID = ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TWILIO_AUTH_TOKEN = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Now you can access environment variables using Sys.getenv(), e.g.:

tw.incoming_phone_numbers.list(
	sid = Sys.getenv('TWILIO_ACCOUNT_SID'), 
	token = Sys.getenv('TWILIO_AUTH_TOKEN'), 
	n = 20
)

Keep in mind the secrets are saved in plaintext on your computer, so this isn't great for non-shared credentials.

About

functions for accessing the twilio API from within R

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages