passing Curl parameter as a parameter
<p>I have a curl function that requests data on Asteroids and get backs results. Currently I am just hard coding in the date parameters for the result, I would like the user to be able to enter their selected dates and get the result how could I add this, I am new to using Curl and keep hitting a wall, the code so far is below,</p>

<pre><code>&lt;?php
session_start();
// Method: POST, PUT, GET etc
// Data: array("param" =&gt; "value") ==&gt; index.php?param=value

function CallAPI($method, $url, $data = false)
{
    $curl = curl_init();

    switch ($method) {
        case "POST":
            curl_setopt($curl, CURLOPT_POST, 1);

            if ($data)
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
            break;
        case "PUT":
            curl_setopt($curl, CURLOPT_PUT, 1);
            break;
        default:
            if ($data)
                $url = sprintf("%s?%s", $url, http_build_query($data));
    }
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    $result = curl_exec($curl);
    if ($result === FALSE) {
        die(curl_error($curl));
    }
    curl_close($curl);
    return $result;
}
$params = array(
    'start_date' =&gt; '01/03/2016',
    'end_date' =&gt; '02/03/2016',
    'api_key' =&gt; 'demo key'
);
$data   = json_decode(callAPI('GET', 'https://api.nasa.gov/neo/rest/v1/feed', $params));

//var_dump($data);

echo "&lt;h1&gt;Near-Earth Object (NEO) Report between " . $params['start_date'] . " and " . $params['end_date'] . "&lt;/h1&gt;";

foreach ($data-&gt;near_earth_objects as $date =&gt; $count) {
    echo "&lt;p&gt;" . sizeof($count) . " objects detected on $date&lt;/p&gt;";

    echo "&lt;ol&gt;";
    foreach ($data-&gt;near_earth_objects-&gt;$date as $near_earth_object) {
        echo "&lt;li&gt;" . $near_earth_object-&gt;name . " &lt;a href='" . $near_earth_object-&gt;nasa_jpl_url . "'&gt;" . $near_earth_object-&gt;nasa_jpl_url . "&lt;/a&gt;&lt;br&gt;";
        echo "Estimated Diameter: " . $near_earth_object-&gt;estimated_diameter-&gt;meters-&gt;estimated_diameter_min . "-" . $near_earth_object-&gt;estimated_diameter-&gt;meters-&gt;estimated_diameter_max . " metres&lt;br&gt;";

        echo "&lt;ul&gt;";
        foreach ($near_earth_object-&gt;close_approach_data as $close_approach) {
            echo "&lt;li&gt;Close approach on " . $close_approach-&gt;close_approach_date . " velocity " . $close_approach-&gt;relative_velocity-&gt;kilometers_per_hour . " km/h " . "missing " . $close_approach-&gt;orbiting_body . " by " . $close_approach-&gt;miss_distance-&gt;kilometers . " km&lt;/li&gt; ";
        }
        echo "&lt;/ul&gt;&lt;/li&gt;";
    }
    echo "&lt;/ol&gt;";
}
?&gt;
</code></pre>