我试图使用Mashape平台来使用R访问不同的API(例如,指导者或pipl)。我可以直接使用原始的API,但是习惯Mashape似乎是一个很好的投资,因为它提供了对大量其他API的统一访问。
然而,有两个关切:
httr包来查询Mashape,但是直到那里才成功。如何用R ?查询Mashape;发布于 2015-05-21 19:58:33
伟大的问题格雷登,
下面是让您入门的代码片段:
查询下个星期在加州洛杉矶的天气预报的气象API!
请记住用自己的:)更改键
#imports an http R library
library(httr)
#perform a GET request on the URL, with two headers and store in a resp variable
resp <- GET("https://george-vustrey-weather.p.mashape.com/api.php?location=Los+Angeles", add_headers("X-Mashape-Key" = "MASHAPE-OWN-KEY","Accept" = "application/json"))
#Prints the headers
headers(resp)
#Prints the content of the response
str(content(resp))希望这能有所帮助!
https://stackoverflow.com/questions/30382196
复制相似问题