What are the potential security risks associated with passing parameters via Curl in PHP scripts?

When passing parameters via Curl in PHP scripts, there is a potential security risk of exposing sensitive information, such as API keys or passwords, in the URL. To mitigate this risk, it is recommended to use the CURLOPT_POSTFIELDS option to send parameters in the request body instead of appending them to the URL.

<?php
$ch = curl_init();
$data = array(
    'param1' => 'value1',
    'param2' => 'value2'
);
curl_setopt($ch, CURLOPT_URL, 'http://example.com/api');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>