rcurl

How to get most popular Facebook post in R

给你一囗甜甜゛ 提交于 2020-01-05 04:08:15
问题 I am trying to use the following code to get posts from a page on Facebook. I get an error even though the query works when I type it in a browser. This is the error I get: WWW-Authenticate: OAuth "Facebook Platform" "invalid_request" "Unknown path components: Any thoughts are greatly appreciated! # go to 'https://developers.facebook.com/tools/explorer' to get your access token access_token <- "### token ###" require(RCurl) require(rjson) cafile <- system.file("CurlSSL", "cacert.pem", package

base64 decode - nul in string

一个人想着一个人 提交于 2020-01-04 13:41:32
问题 I'm trying to create function that will run private API calls on some sites. All those sites are using authentication by signature of the API call as follows in php: base64_encode( hash_hmac('sha512', $post_data, base64_decode($secret), true) ) Using package digest and RCurl I can easily write as: base64Encode( hmac(key = base64Decode(secret), object = post_data, algo = 'sha512', raw = TRUE) ) I'm fighting whole day with the hmac key parameter input: key = base64Decode(secret) The issue is

Create a C-level file handle in RCurl for writing downloaded files

試著忘記壹切 提交于 2020-01-03 08:56:10
问题 In RCurl a function and a class CFILE is defined to work with C-level file handles. From the manual: The intent is to be able to pass these to libcurl as options so that it can read or write from or to the file. We can also do this with R connections and specify callback functions that manipulate these connections. But using the C-level FILE handle is likely to be significantly faster for large files. There are no examples related to downloads so I tried: library(RCurl) u = "http://cran.r

415 code using httr and RCurl, but not just curl

僤鯓⒐⒋嵵緔 提交于 2020-01-02 10:22:34
问题 I'm trying to write a function that handles some of the authentication for Spotify's API. I can get it to work with a fairly simple curl command, but when I try to use httr or RCurl, I get 415 Unsupported Media Type responses. I'm somewhat at a loss at this point. I've gotten POST() , and GET() to work with this API already, but this endpoint is not working. Using httr : response <- POST('https://accounts.spotify.com/api/token', accept_json(), add_headers('Authorization'=paste('Basic',base64

RCurl and self-signed certificate issues

两盒软妹~` 提交于 2020-01-02 03:06:50
问题 I am having problems getting RCurl function getURL to access an HTTPS URL on a server that is using a self-signed certificate. I'm running R 3.0.2 on Mac OS X 10.9.2. I have read the FAQ and the curl page on the subject. So this is where I stand: I have saved a copy of the certificate to disk (~/cert.pem). I have been able to use this very same file to connect to the server using python-requests and the 'verify' option, and succeeded. curl on the command-line seems to be ignoring the --cacert

Debugging RCurl-based authentication & form submission

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-02 00:39:26
问题 SourceForge Research Data Archive (SRDA) is one of the data sources for my dissertation research. I'm having difficulty in debugging the following issue related to SRDA data collection. Data collection from SRDA requires authentication and then submitting Web form with an SQL query. Upon successful processing of the query, the system generates a text file with query results . While testing my R code for SRDA data collection, I've changed the SQL request to make sure that the results file is

How to specify certificate, key and root certificate with httr for certificate based authentication?

荒凉一梦 提交于 2019-12-30 10:35:42
问题 I am trying to access data using httr library from server which expects certificate based authentication. I have certificate (cert.pem), key file (key.pem) and root certificate (caroot.pem) Following curl works. curl -H "userName:sriharsha@rpc.com" --cert cert.pem --key certkey.key --cacert caroot.pem https://api.somedomain.com/api/v1/timeseries/klog?limit=1 How can specify certkey.key and caroot.pem to httr GET request. I am trying with following R command but couldn't find option to specify

How can I POST a simple HTML form in R?

微笑、不失礼 提交于 2019-12-30 00:39:11
问题 I'm relatively new to R programming and I'm trying to put some of the stuff I'm learning in the Johns Hopkins Data Science track to practical use. Specifically, I would like to automate the process of downloading historical bond prices from the US Treasury website Using both Firefox and R, I was able to determine that the US Treasury website uses a very simple HTML POST form to specify a single date for the quotes of interest. It then returns a table of secondary market information for all

How do I POST a JSON formatted request to GET JSON data from a URL in R into the data.frame in a less verbose manner?

梦想与她 提交于 2019-12-29 08:10:40
问题 I have written the following code in R to start using a data request API. It's a normal web service JSON API. library(RJSONIO) library(RCurl) library(httr) r <- POST("http://api.scb.se/OV0104/v1/doris/sv/ssd/START/PR/PR0101/PR0101A/KPIFastM2", body = '{ "query": [], "response": { "format": "json" } }') stop_for_status(r) a<-content(r, "text", "application/json", encoding="UTF-8") cat(a, file = "test.json") x<-fromJSON(file("test.json", "r")) mydf<-do.call(rbind, lapply(x$data, data.frame))

how to download a large binary file with RCurl *after* server authentication

那年仲夏 提交于 2019-12-29 06:49:27
问题 i originally asked this question about performing this task with the httr package, but i don't think it's possible using httr . so i've re-written my code to use RCurl instead -- but i'm still tripping up on something probably related to the writefunction .. but i really don't understand why. you should be able to reproduce my work by using the 32-bit version of R, so you hit memory limits if you read anything into RAM. i need a solution that downloads directly to the hard disk. to start,