How to properly use curl_init for a GET request in PHP? or Why is my curl_init GET request not workin

24 Replies, 2102 Views

Bro, you’re on the right track. The code’s fine for a basic GET request.

But APIs can be picky—sometimes you need headers. Try adding:
```php
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Accept: application/json']);
```
If the API expects JSON. Also, `var_dump($response)` to see raw output.

Messages In This Thread



Users browsing this thread: 1 Guest(s)