{"success":false,"errors":[{"code":10000,"message":"Authentication error"}]}

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, 'https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/purge_cache');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"purge_everything\":true}");
        curl_setopt($ch, CURLOPT_POST, 1);
        
        $headers = array();
        $headers[] = 'X-Auth-Email: $cloudflare_user_email';
        $headers[] = 'X-Auth-Key: $global_key';
        $headers[] = 'Content-Type: application/json';
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        
        echo $result = curl_exec($ch);
        if (curl_errno($ch)) {
            echo 'Error:' . curl_error($ch);
        }
        curl_close ($ch);

API respond of the above code, always getting me the response like the following. Please anyone help me on this.

{“success”:false,“errors”:[{“code”:10000,“message”:“Authentication error”}]}

Has this ever worked?

1 Like

No its not worked … It is the first time I am using API from cloudflare … Also, I am trying this API from My localhost. Do that makes any problem?