M.toast({html: '".$message."',classes:'red darken-4'});"; }else{ echo ""; } } //function to send SMS function sendSMS($phoneNumber,$textMessage) { // create a new cURL resource $ch = curl_init(); $smsPhoneNumber = "[[TOKY_SMS_PHONE_NUMBER]]"; $api_key = '[[TOKY_API_KEY]]';//'[[TOKY_API_KEY]]'; $headers = array(); $headers[] = "X-Toky-Key: {$api_key}"; $data = array("from" => $smsPhoneNumber, "email" => "[[AGENT_EMAIL]]", "to" => $phoneNumber, "text" => $textMessage); $json_data = json_encode($data); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "https://api.toky.co/v1/sms/send"); curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch,CURLOPT_POSTFIELDS, $json_data); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, TRUE); curl_setopt ($ch, CURLOPT_CAINFO, dirname(__FILE__)."/cacert.pem"); $curl_response = curl_exec($ch); // Send request curl_close($ch); // close cURL resource $decoded = json_decode($curl_response,true); //Return error message if the message can't be sent if (!$decoded["success"]){ $result= "Error sending SMS to $phoneNumber: ".$decoded["error_message"]; }else{ $result='SMS sent successfully'; } return $result; } ?> Document
0) { ?>
  • Results

  • sms
    sms_failed

Comments