Description Usage Token registration Setting a user agent Environment variables Examples
store_creds
prompts you for a Newsriver API token and user agent and
permanently stores them so they are available for every R
session.
store_creds_temp
prompts you for a Newsriver API token and user agent
and temporarily stores them so they are available for only the
current R session.
1 2 3 |
To register for an API token, visit the Newsriver site and follow the sign up procedures. Registration is free.
The user agent is a string used to identify the client. This allows Newsriver to identify who is using the API (and is important if something goes wrong). A good default user agent is your email address. Note: the user agent you supply does not need to be wrapped in quotes (nor does the API token).
Both store_creds
and store_creds_temp
store the supplied API
token and user agent as environment variables called "NEWSRIVER_API_KEY" and
"NEWSRIVER_USER_AGENT" respectively. These environment variables are then
called by other newsrivr functions.
To store these environment variables, store_creds
tries to find a
.Renviron file located in your home directory. If no .Renviron file can be
found, one will be created. Warning: only call store_creds
once to prevent multiple environment variables being stored.
If you do not want to alter your global .Renviron file, then use
store_creds_temp
which stores environment variables for only the
current R session. Alternatively an API token and user agent can be passed as
arguments directly into the relevant newsrivr functions. This method is not
recommended as credentials can accidentally get leaked in scripts and .Rhistory
files.
1 2 3 4 5 6 | ## Not run:
store_creds() # you will be prompted to enter your credentials
store_creds_temp() # you will be prompted to enter your credentials
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.