REF :
knitr::opts_chunk$set(echo = TRUE, comment = " ##", error = TRUE, collapse = TRUE) library(httr2) library(DiagrammeR)
GOAL http://www.opensecrets.org/api/?method=getLegislators&id=NJ&apikey=__apikey__ #Works in browser (returns xml) #https://opensecrets.org/api/?method=getLegislators&id=NJ&apikey={{key}} from firefox this is curl and this seems to work at CLI (but says binary output, which might screw up screen, so I do not proceed) curl 'https://www.opensecrets.org/api/?method=getLegislators&id=NJ&apikey=6228a3fb184b949386fd16176fb7bfc6' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br' -H 'Connection: keep-alive' -H 'Cookie: _opensecrets_session=6TLVjGNw0m6NaHrni2BNJRxNO96l9wERc233QWxdQeBm%2FbfXgn%2FltovOCVCscfPyRAsMjx2Ms6WTllNxxRXMfJsEZhNQE2%2BcRiWGTc26IiSNM5UsbFCsmJeirFvulrLT5zisGJuLH2tFQWF5%2BRbqkLB4MM7YIUtRPKGB1f9Km01AASX6WFN6oIa%2B2MEPYozrKbKznGf4mD6rGBDDzLP7e4A1mRkVKJB4Ju8ru91SZ1wYR6O%2BVCgvgIXKuVJp9dEQwelGmD07WCjDzvcGT50iwQbzJJhhzPjpVqmaxw%3D%3D--AuF%2FW2TLfPdtT6Nl--JaxfO7QGs2JpMCzZ8GU%2B4w%3D%3D; PHPSESSID=qhjhgh6u6lptlqd28m9rqglc13' -H 'Upgrade-Insecure-Requests: 1' -H 'Sec-Fetch-Dest: document' -H 'Sec-Fetch-Mode: navigate' -H 'Sec-Fetch-Site: cross-site' -H 'Cache-Control: max-age=0' -H 'TE: trailers'
key <- Sys.getenv("OS_API_KEY")
url <- paste0( "http://www.opensecrets.org/api/?method=getLegislators&id=NJ&apikey=", key) request(url) |> req_headers("ACCEPT" = "application/json") |> req_dry_run() resp <- request(url) |> req_headers("ACCEPT" = "application/json") |> req_perform()
str <- "curl http://httpd.org" curl_translate(str) curl_translate("curl http://example.com --header A:1 --header B:2") ## curl usage -- very abbreviated curl_help()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.