You are here

function nexmo_receive_message in Nexmo SMS Gateway 7

Receive an SMS message and pass it into the SMS Framework.

1 string reference to 'nexmo_receive_message'
nexmo_menu in ./nexmo.module
Implements hook_menu().

File

./nexmo.module, line 133
Provides NEXMO implementation methods.

Code

function nexmo_receive_message() {
  if (!isset($_REQUEST['text'], $_REQUEST['msisdn'], $_REQUEST['to'])) {
    return FALSE;
  }
  else {
    $number = $_REQUEST['msisdn'];
    $message = $_REQUEST['text'];
    $options = array();
    if (array_key_exists('to', $_REQUEST) && !empty($_REQUEST['to'])) {
      $options['receiver'] = $_REQUEST['to'];
    }
    if (array_key_exists('network-code', $_REQUEST) && !empty($_REQUEST['network-code'])) {
      $options['network-code'] = $_REQUEST['network-code'];
    }
    if (array_key_exists('message-timestamp', $_REQUEST) && !empty($_REQUEST['message-timestamp'])) {
      $options['message-timestamp'] = $_REQUEST['message-timestamp'];
    }
    if (array_key_exists('messageId', $_REQUEST) && !empty($_REQUEST['messageId'])) {
      $options['messageId'] = $_REQUEST['messageId'];
    }
    sms_incoming($number, $message, $options);
    print "response 200 OK";
  }
}