php - CallAPI function does not work after WordPress updates

one text

i have a problem after a Wordpress Update.

I created a WP plugin that generates an html form with hidden input parameters and sends the data in a php file which in turn sends via CallAPI to an external api.

after this update the function no longer makes the api call.

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("&", $url, http_build_query($data));
    }

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

        $result = curl_exec($curl);

        curl_close($curl);

        return $result;
}


$url = 'https://www.example.com/addlead?api_key=';

$api_key = $_GET["api_key"];
$off = $_GET["off"];
$net = $_GET["net"];
$aff = $_GET["aff"];
$cid = $_GET["cid"];
$firstname = $_GET["name"];
$phone = $_GET["phone"];
$address = $_GET["street"];
$city = $_GET["city"];
$zipcode = $_GET["cap"];
$qty = 1;
$note = $_GET["note"];
$dto = $_GET["dto"];

$make_call = CallAPI('POST', $url . 
                    $api_key . '&off=' . 
                    $off . '&net=' . 
                    $net . '&aff=' . 
                    $aff = urlencode($aff) . '&cid=' . 
                    $cid = urlencode($cid) . '&firstname=' . 
                    $firstname = urlencode($firstname) . '&phone=' . 
                    $phone = urlencode($phone) . '&address=' . 
                    $address = urlencode($address) . '&city=' . 
                    $city = urlencode($city) . '&zipcode=' . 
                    $zipcode = urlencode($zipcode) . '&qty=' . 
                    $qty . '&note='.
                    $note = urlencode($note) . '&dto=' .
                    $dto = urlencode($dto));

$addlead_json = $make_call;
$addlead_json_dec = json_decode($addlead_json, true);

does anyone know of an alternative method to make an api call with php?

Source