curl -X GET \
-H "X-Algolia-API-Key: ${API_KEY}" \
-H "X-Algolia-Application-Id: ${APPLICATION_ID}" \
--compressed \
"https://status.algolia.com/1/status"
任何人都可以告诉我如何将这个cURL命令写入php代码?
答案 0 :(得分:1)
这些方面的东西:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://status.algolia.com/1/status");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
$headers = array();
$headers[] = "X-Algolia-Api-Key: " . $api_key];
$headers[] = "X-Algolia-Application-Id: " . $application_id];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
答案 1 :(得分:0)
查看Curl PHP Run code中的答案 它应该为您提供所需的信息。