How to properly use curl_init for a GET request in PHP? or What's the correct way to handle a curl_in

18 Replies, 1465 Views

Hey! I had the same issue with my curl_init get request last week. Turns out, the server might be blocking it. Try adding a user agent like this:

```php
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0');
```

Also, check if the URL is actually reachable—sometimes it’s just a typo.

For debugging, use `curl_error($ch)` right after `curl_exec` to see what’s going wrong.

Messages In This Thread



Users browsing this thread: 1 Guest(s)