【发布时间】:2018-05-23 16:45:26
【问题描述】:
我想使用 jsonWhois api,但它使用 Unirest 发出服务器请求,看起来它已不再维护,我更喜欢使用 curl。
如何将此代码转换为使用 Curl??
$response = Unirest\Request::get("https://jsonwhois.com/api/v1/whois",
array(
"Accept" => "application/json",
"Authorization" => "Token token=<Api Key>"
),
array(
"domain" => "google.com"
)
);
$data = $response->body; // Parsed body
我试过curl_setopt($ch, CURLOPT_URL, 'https://jsonwhois.com/api/v1/whois?token=123456&domain=google.com');,但它显示HTTP Token: access denied。
【问题讨论】:
-
查看原始代码,似乎令牌需要在标头中发送,而不是作为查询参数。