Rest with Curl does not return anything This is the code. 
I am using a rest api to and http authentication to authenticate the user.
On running the function, nothing is getting displayed.
I am not getting a success/error from the response. The response is blank and there is no error as well. Please help
<?php
$method = "POST";
$url = "https://www.myproject.com/api/v1/projects/create";
$data_array = array("projectName"=>"Project1");
$data = json_encode($data_array);
$response = CallAPI($method,$url,$data);

function CallAPI($method, $url, $data)
{
    $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));
    }

    // Optional Authentication:
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    //base64
    curl_setopt($curl, CURLOPT_USERPWD, "anemail@gmail.com:arpit.1995");

    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

    $result = curl_exec($curl);

    curl_close($curl);

    return $result;

}
$response = CallAPI($method,$url,$data);
echo $response;
?>