从技术上讲,这不是完整的 R 答案,但他们在 API 提供程序页面上给出的示例在 R 中使用 RCurl 包是 100% 可行的:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$apiKey = '<Your API Key>';
$url = 'https://apifa.shoothill.com/Account/APILogin/';
$postinfo = "apikey=".$apiKey."&persist=false";
$cookie_file_path = dirname(__FILE__) . "cookie.txt";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIE, "cookiename=1");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $_SERVER['REQUEST_URI']);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postinfo);
$out = curl_exec($ch);
curl_setopt($ch, CURLOPT_HTTPGET, 1);
curl_setopt($ch, CURLOPT_URL, "https://apifa.shoothill.com/API/Floods");
curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type: application/json'));
$html = curl_exec($ch);
curl_close($ch);
echo $html;
return $html;
?>
OmegaHat 有一个很详细的explanationRCurl 的使用方法,看完之后你应该可以很好的翻译上面的内容了。