"Having trouble with curl_init GET request—any solutions?"
Hey guys,
I’m trying to make a simple curl_init get request in PHP, but it’s not working like I expected.
Here’s what I’ve got:
```php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://example.com/api?param=test");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
```
But the response is empty or errors out. Am I missing something obvious?
Also, is there a better way to handle curl_init get requests? Like, should I be setting more options or checking for errors differently?
Any help would be awesome—thanks in advance!
(PS: If you’ve got a working example, that’d be even better!)
Hey guys,
I’m trying to make a simple curl_init get request in PHP, but it’s not working like I expected.
Here’s what I’ve got:
```php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://example.com/api?param=test");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
```
But the response is empty or errors out. Am I missing something obvious?
Also, is there a better way to handle curl_init get requests? Like, should I be setting more options or checking for errors differently?
Any help would be awesome—thanks in advance!
(PS: If you’ve got a working example, that’d be even better!)
