I did not attach the full code, but with your modifications it looks like this and I also made the changes on Global and Conditions:
// User object
$result = $user;
if($result<>'' || $result<>''){ //Only if number has been entered in phone field
$mode = 'send';
if ($result<>'') {$phone[] = "45" . $result;}
if ($result<>'') {$phone[] = "45" . $result;}
$message = "Hej\n\nDu har stadig ikke betalt dit ventelistegebyr! Du vil blive slettet fra ventelisten inden 5 dage, hvis du ikke betaler! For hjælp skriv til vente@xxxxxx.dk, med dit ventelistenummer (" . $result . ").
\n\nDu kan IKKE svare på denne SMS!";
//set POST variables
$url = '
api.xxxxxx.dk/v2/send
';
//$message = rawurlencode($message);
$fields = array(
'to' => $phone,
'message' => $message,
'from' => 'xxxxxx'
);
$fields_string = $payload = json_encode($fields);
/*
$fields_string="";
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
*/
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
$headers = array(
"Accept: application/json",
"Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"Content-Type: application/json",
);
curl_setopt($ch,CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_PORT, $serverport);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
//execute post
$response = curl_exec($ch);
//close connection
curl_close($ch);
mail("mail@xxxxxx.dk","Mail fra xxxxxxx - husk at slå fra igen !!",$response);