3

I am trying to access an API URL using curl, which has worked perfectly on my computer. But once I moved over my website to a VPS it suddenly stopped working, due to that the API-Host is using cloudflare, and since my VPS-IP eventually looks "suspect", it forces me to pass this 5 second firewall before I visit the site.

I don't know how I can bypass this, or somehow get trough this layer using curl.

This is my code.

curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt ($ch, CURLOPT_ENCODING,  '');
        curl_setopt ($ch, CURLOPT_MAXREDIRS, 10);
        curl_setopt ($ch, CURLOPT_TIMEOUT, 180);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt ($ch, CURLOPT_FAILONERROR, true);
        curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
        $result = curl_exec($ch);
        curl_close ($ch);

I have tried to set a specific browser for the curl request, and see if that works, but no, the API won't give me anything back except nullpointers.

Any help appreciated.

  • See if you can contact the devs of the website. They can either whitelist your IP or prevent the API routes from being subjected to rate limiting challenges. – aynber Dec 20 '19 at 13:54
  • The owners just told me to get a new IP. But how can I know that the new IP won't be suspected either? – Emrik Ahlström Dec 20 '19 at 13:59
  • Wow, that's bad advice, since it's not foolproof, and changing IPs can be difficult if it's a full fledged previously-existing site. You really don't know that the new IP won't have the same issue until you change it. You could be IP hopping for weeks trying to find a good one. – aynber Dec 20 '19 at 14:01
  • Yea exactly. I will try a PHP library that eventually can bypass their protection. – Emrik Ahlström Dec 20 '19 at 14:14
  • Did you try with ssl ? –  Dec 20 '19 at 14:34
  • How do I do that? – Emrik Ahlström Dec 20 '19 at 15:05

0 Answers0