Exemple API SMS PHP


<?php
$token = "your.token"; // https://app.smsup.ch/developers/api-tokens
$content = "Test API";
$numbers = array('0601020304','0704030201');
$sender = "PHP";
$recipients = array();
foreach ($numbers as $n) {
  $recipients[] = array('value' => $n);
}

$postdata = array(
  'sms' => array(
   'message' => array(
    'text' => $content,
    'sender' => $sender
   ),
   'recipients' => array('gsm' => $recipients)
  )
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.smsup.ch/send");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postdata));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json', 'Authorization: Bearer ' . $token));
$response = curl_exec($ch);
curl_close($ch);