gar_batch | R Documentation |
Turn a list of gar_fetch_functions into batch functions
gar_batch(
function_list,
...,
batch_endpoint = getOption("googleAuthR.batch_endpoint", default =
"https://www.googleapis.com/batch")
)
function_list |
a list of functions from |
... |
further arguments passed to the data parse function of f |
batch_endpoint |
the batch API endpoint to send to |
This function will turn all the individual Google API functions into one POST request to /batch.
If you need to pass multiple data parse function arguments its probably best to do it in separate batches to avoid confusion.
A list of the Google API responses
https://developers.google.com/webmaster-tools/v3/how-tos/batch
Documentation on doing batch requests for the search console API. Other Google APIs are similar.
Walk through API calls changing parameters using gar_batch_walk
Other batch functions:
gar_batch_walk()
## Not run:
## usually set on package load
options(googleAuthR.batch_endpoint = "https://www.googleapis.com/batch/urlshortener/v1")
## from goo.gl API
shorten_url <- function(url){
body = list(longUrl = url)
f <- gar_api_generator("https://www.googleapis.com/urlshortener/v1/url",
"POST",
data_parse_function = function(x) x$id)
f(the_body = body)
}
## from goo.gl API
user_history <- function(){
f <- gar_api_generator("https://www.googleapis.com/urlshortener/v1/url/history",
"GET",
data_parse_function = function(x) x$items)
f()
}
gar_batch(list(shorten_url("http://markedmondson.me"), user_history()))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.