Error while accessing api on a site protected by cloudflare

   $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $api_url);
    curl_setopt($ch, CURLOPT_POST, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($ch);
    print_r($result );

I was using API on some website it was working fine until it implemented cloudflare’s protection. I used the above code to request some data and the output was the cloudflare’s page saying “Checking your browser before accessing”

What am I doing wrong. Is there any solution. Do i need to change the code or contact the website to whitelist my server’s ip ?

They may have enabled a bot fight mode with a Challenge setting. You’d have to ask them if they changed anything recently.

When i contacted them they said enable forwarding in your request I added $ch, CURLOPT_FOLLOWLOCATION, true
but it didn’t help.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.