<?php
 function sendMessage($number, $message) {
  $fields = array(
      'message' => $message,
      'phone_number' => $number 
  );

  $fields = json_encode($fields);
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "https://www.smson.ph/api/v1/send-sms");
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "SmsOn-Auth: YmVuamFyZGlyQGdtYWlsLmNvbTpwYXNzd29yZA==",
    "SmsOn-ApiKey: 2y10gqhGf2JOo4BUIO8xcsDvuh2r4uKW3hgbKyBKDdW1O1IfWSCgXryK"));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($ch,CURLOPT_ENCODING , "");
  curl_setopt($ch,CURLOPT_MAXREDIRS , 10);
  curl_setopt($ch,CURLOPT_TIMEOUT , 0);
  curl_setopt($ch,CURLOPT_FOLLOWLOCATION ,FALSE);
  curl_setopt($ch,CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1);  
  curl_setopt($ch, CURLOPT_HEADER, FALSE); 
  curl_setopt($ch,CURLOPT_CUSTOMREQUEST ,"POST");
  // foreach ($fields as $fn) {
    //  curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents($fn));  
      //$result = curl_exec($ch);
      //$info = curl_getinfo($ch); 
      //var_dump($info);
      //if ($result === false) {
      //die(curl_error());
      ///}else{
      //echo "<br />".$fn." upload ok"."<br />";
      // }
  // }
  curl_setopt($ch,  CURLOPT_POSTFIELDS , array('message' => $message,'phone_number' => $number));
  $response = curl_exec($ch);
  curl_close($ch);
  
  return $response;
  $response = curl_exec($ch);
  curl_close($ch);
}

$response = sendMessage($number, $message);
// $return["allresponses"] = $response;
// $return = json_encode($return);
?>