jason jason - 1 year ago 104
PHP Question

How to convert this from curl to php

Does someone know how to convert this from to php? Or maybe can convert.

curl -X DELETE "https://api.cloudflare.com/client/v4/zones/fjsdf834u8fhsdfh343/purge_cache" \
-H "X-Auth-Email: user@example.com" \
-H "X-Auth-Key: c254fsdfg34320b638f5e225c545fsddasc5cfdda41" \
-H "Content-Type: application/json" \
--data '{"purge_everything":true}'

Answer Source
$ch = curl_init ('https://api.cloudflare.com/client/v4/zones/fjsdf834u8fhsdfh343/purge_cache');
curl_setopt ($ch,  CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt ($ch, CURLOPT_HTTPHEADER, array (
    'X-Auth-Email: user@example.com',
    'X-Auth-Key: c254fsdfg34320b638f5e225c545fsddasc5cfdda41',
    'Content-Type: application/json'

curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, '{"purge_everything":true}');

echo curl_exec ($ch);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download