Your code’s good, but for better error handling, wrap it in a try-catch and check the HTTP code:
```php
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode != 200) {
throw new Exception("API returned $httpCode");
}
```
Makes debugging way easier.
```php
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode != 200) {
throw new Exception("API returned $httpCode");
}
```
Makes debugging way easier.
