-1
curl -X GET \
     -H "X-Algolia-API-Key: ${API_KEY}" \
     -H "X-Algolia-Application-Id: ${APPLICATION_ID}" \
     --compressed \
    "https://status.algolia.com/1/status"

Can anyone please tell me how can i write this cURL command into php code?

Parvez Rahaman
  • 4,269
  • 3
  • 22
  • 39

2 Answers2

1

Something along these lines:

$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);
John C
  • 8,223
  • 2
  • 36
  • 47
0

Have a look at the answers in Curl PHP Run code It should give you the info you need.

Community
  • 1
  • 1
Simon Deconde
  • 309
  • 1
  • 4