I have an Axios HTTP GET request I'd to convert to PHP cURL.
Axios Request
axios({
    method: 'get',
    url: 'https://api.sample.com/123456789/',
    data: {
        apikey: '987654321',
        id: '123123',
    }
}).then(function ( response ) {
    console.log( response );
});
How do I make this request in PHP cURL, sending the apikey and id data, then echoing the response?
cURL I Was Trying
<?php
$url = 'https://api.sample.com/123456789/';
$body_arr = [
    'apikey' => '987654321',
    'id' => '123123',
];
$data = http_build_query($body_arr);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$result_arr = json_decode($result, true);
echo '<pre>';
var_dump( $result_arr );
echo '</pre>';
?>
Result
NULL
 
    