<?php include "lib/NexmoMessage.php"; // Step 1: Declare new NexmoMessage. $no = $_POST['phone_no']; $txt = $_POST['sms_body']; $nexmo_sms = new NexmoMessage('6e4d6866', '2af8f65e'); // Step 2: Use sendText( $to, $from, $message ) method to send a message. $info = $nexmo_sms->sendText($no, 'Clr-bld/sms-service', $txt); // Step 3: Display an overview of the message echo $nexmo_sms->displayOverview($info); // Done!
public function inform_insert_client($data, $msg, $term_num) { $adder = $this->db->prepare("INSERT INTO msg_details (number,message,termid)\n VALUES(:number,:message,:termid)"); $adder->execute(array(':number' => $data, ':message' => $msg, 'termid' => $term_num)); include "public/sms/src/NexmoMessage.php"; $nexmo_sms = new NexmoMessage('32a68cfb', '597cecf7'); $info = $nexmo_sms->sendText($data, 'TrainXLIfe', $msg); echo $nexmo_sms->displayOverview($info); }
function NexmoVerify($api_key, $api_secret) { parent::NexmoMessage($api_key, $api_secret); // setup verify parameters $this->nx_uri = 'https://api.nexmo.com/verify/json'; $this->nx_key_varname = 'api_key'; $this->nx_secret_varname = 'api_secret'; }
/** * @return mixed */ public function send($to, $message, $title = "") { include_once Kohana::find_file('vendor', 'nexmo/NexmoMessage'); if (!isset($this->_client)) { $this->_client = new NexmoMessage($this->_options['api_key'], $this->_options['api_secret']); } // Send! try { $info = $this->_client->sendText('+' . $to, '+' . preg_replace("/[^0-9,.]/", "", $this->from()), $message); foreach ($info->messages as $message) { if ($message->status != 0) { Kohana::$log->add(Log::ERROR, 'Nexmo: ' . $message->errortext); return array(Message_Status::FAILED, FALSE); } return array(Message_Status::SENT, $message->messageid); } } catch (Exception $e) { Kohana::$log->add(Log::ERROR, $e->getMessage()); } return array(Message_Status::FAILED, FALSE); }
<?php include "NexmoMessage.php"; /** * To send a text message. * */ // Step 1: Declare new NexmoMessage. $nexmo_sms = new NexmoMessage('api_key', 'api_secret'); // Step 2: Use sendText( $to, $from, $message ) method to send a message. $info = $nexmo_sms->sendText('+447234567890', 'MyApp', 'Hello!'); // Step 3: Display an overview of the message echo $nexmo_sms->displayOverview($info); // Done!
public function nexmo($to, $message) { if ($this->settings['nexmoApiKey'] == "" || $this->settings['nexmoApiSecret'] == "") { return; } $nexmo_sms = new NexmoMessage($this->settings['nexmoApiKey'], $this->settings['nexmoApiSecret']); $info = $nexmo_sms->sendText($to, $this->title, $message); }
/** * Handle SMS from Nexmo */ public function action_reply() { include_once Kohana::find_file('vendor', 'nexmo/NexmoMessage'); // Pong Sender $ip_address = $_SERVER["REMOTE_ADDR"]; $continue = FALSE; foreach ($this->subnets as $subnet) { if ($this->_ip_in_range($ip_address, $subnet)) { throw HTTP_Exception::factory(403, 'IP Address not in allowed range'); break; } } $provider = DataProvider::factory('nexmo'); $options = $provider->options(); if (!isset($options['api_key'])) { throw HTTP_Exception::factory(403, 'Missing API key'); } if (!isset($options['api_secret'])) { throw HTTP_Exception::factory(403, 'Missing API secret'); } $sms = new NexmoMessage($options['api_key'], $options['api_secret']); if (!$sms->inboundText()) { throw HTTP_Exception::factory(400, "Invalid message"); } // Remove Non-Numeric characters because that's what the DB has $to = preg_replace("/[^0-9,.]/", "", $sms->to); $from = preg_replace("/[^0-9,.]/", "", $sms->from); $provider->receive(Message_Type::SMS, $from, $sms->text, $to, NULL, $sms->message_id); }
public function SendSms($contact) { include "/libs/sms/src/NexmoMessage.php"; $newCon = substr($contact, 1); // Step 1: Declare new NexmoMessage. $nexmo_sms = new NexmoMessage('e3a975e2', 'ffdd4630'); // Step 2: Use sendText( $to, $from, $message ) method to send a message. $info = $nexmo_sms->sendText('+94' . $newCon, 'IOC', 'Dear Customer your Carwash service is done. You can collect your vehicle at our service station. Thank You for using our service.'); // Step 3: Display an overview of the message echo $nexmo_sms->displayOverview($info); // Done! }
if (LS_TW_SID && LS_TW_TOKEN) { $lsdb->query('SELECT id FROM ' . DB_PREFIX . 'user WHERE access = 1 AND available = 1'); if ($lsdb->affected_rows == 0) { $result = $lsdb->query('SELECT phonenumber FROM ' . DB_PREFIX . 'user WHERE access = 1 AND available = 0 AND phonenumber != "" AND (departments = 0 OR FIND_IN_SET(' . $depsql . ', departments)) AND FIND_IN_SET("' . date("D") . '", tw_days) AND (TIME(NOW()) >= tw_time_from AND TIME(NOW()) <= tw_time_to)'); if ($lsdb->affected_rows > 0) { if (LS_TWILIO_NEXMO) { require 'include/twilio/Twilio.php'; $client = new Services_Twilio(base64_decode(LS_TW_SID), base64_decode(LS_TW_TOKEN)); while ($row = $result->fetch_assoc()) { $message = $client->account->sms_messages->create(LS_TW_PHONE, $row['phonenumber'], LS_TW_MSG); } } else { include 'include/nexmo/NexmoMessage.php'; while ($row = $result->fetch_assoc()) { // Step 1: Declare new NexmoMessage. (Api Key) (Api Secret) $nexmo_sms = new NexmoMessage(base64_decode(LS_TW_SID), base64_decode(LS_TW_TOKEN)); // Step 2: Use sendText( $to, $from, $message ) method to send a message. $info = $nexmo_sms->sendText($row['phonenumber'], LS_TITLE, LS_TW_MSG); } } } } } } // Redirect page $gochat = LS_rewrite::lsParseurl('chat', $_POST['slide_chat'], $_POST['lang'], '', ''); /* Outputtng the error messages */ if ($_SERVER['HTTP_X_REQUESTED_WITH']) { header('Cache-Control: no-cache'); die(json_encode(array('login' => 1, 'link' => html_entity_decode($gochat)))); }
/** * Handle SMS from Nexmo */ public function action_reply() { include_once Kohana::find_file('vendor', 'nexmo/NexmoMessage'); //Check if data provider is available $providers_available = Kohana::$config->load('features.data-providers'); if (!$providers_available['nexmo']) { throw HTTP_Exception::factory(403, 'The Nexmo data source is not currently available. It can be accessed by upgrading to a higher Ushahidi tier.'); } // Pong Sender $ip_address = $_SERVER["REMOTE_ADDR"]; $continue = FALSE; foreach ($this->subnets as $subnet) { if ($this->_ip_in_range($ip_address, $subnet)) { throw HTTP_Exception::factory(403, 'IP Address not in allowed range'); break; } } $provider = DataProvider::factory('nexmo'); $options = $provider->options(); if (!isset($options['api_key'])) { throw HTTP_Exception::factory(403, 'Missing API key'); } if (!isset($options['api_secret'])) { throw HTTP_Exception::factory(403, 'Missing API secret'); } $sms = new NexmoMessage($options['api_key'], $options['api_secret']); if (!$sms->inboundText()) { throw HTTP_Exception::factory(400, "Invalid message"); } // Remove Non-Numeric characters because that's what the DB has $to = preg_replace("/[^0-9,.]/", "", $sms->to); $from = preg_replace("/[^0-9,.]/", "", $sms->from); $provider->receive(Message_Type::SMS, $from, $sms->text, $to, NULL, $sms->message_id); }
<?php include "lib/NexmoMessage.php"; $msg = new NexmoMessage('6e4d6866', '2af8f65e'); $txt = $msg->inboundText(); echo $txt;
<?php include "NexmoMessage.php"; $sms = new NexmoMessage(getenv('key'), getenv('secret')); if ($sms->inboundText()) { // database details $con = mysql_connect(getenv('MYSQL_DB_HOST'), getenv('MYSQL_USERNAME'), getenv('MYSQL_PASSWORD')); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db(getenv('MYSQL_DB_NAME'), $con); $text = trim($sms->text); // new poll if (strcasecmp($text, 'ask') == 0) { // Create new poll and text user function createPoll($sms) { mysql_query("INSERT INTO Poll (phone, isActive) VALUES ('{$sms->from}', 1)"); $id = mysql_insert_id(); $sms->reply("You've asked a new poll! Tell others to text '{$id} [letter of choice]' to 305-222-7004 to vote. Reply 'TALLY {$id}' to stop this poll and get results."); } // Find this user $result = mysql_query("SELECT remaining FROM Person WHERE phone = {$sms->from}"); if (mysql_num_rows($result) == 0) { // This is a new, unrecognized user. Create a user account for them. mysql_query("INSERT INTO Person (phone, remaining) VALUES ('{$sms->from}', 49)"); createPoll($sms); } else { // User found $row = mysql_fetch_assoc($result); $remaining = $row['remaining'];