예제 #1
0
 /**
  * Sends a SMS message.
  *
  * @param \SimpleSoftwareIO\SMS\OutgoingMessage $message
  */
 public function send(OutgoingMessage $message)
 {
     $from = $message->getFrom();
     $composeMessage = $message->composeMessage();
     foreach ($message->getTo() as $to) {
         $response = $this->plivo->send_message(['dst' => $to, 'src' => $from, 'text' => $composeMessage]);
         if ($response['status'] != 202) {
             $this->SMSNotSentException($response['response']['error']);
         }
     }
 }
예제 #2
0
 /**
  * Sends SMS message
  *
  * @return array
  * @throws DestinationSMSNumberIsEmptyException
  * @throws MessageIsEmptyException
  * @throws SourceSMSNumberIsEmptyException
  */
 public function sendMessage()
 {
     if (empty($this->sourceNumber) && !empty(env('PLIVO_SOURCE_NUMBER'))) {
         $this->setSourceNumber(env('PLIVO_SOURCE_NUMBER'));
     }
     if (empty($this->sourceNumber) && empty(env('PLIVO_SOURCE_NUMBER'))) {
         throw new SourceSMSNumberIsEmptyException('Source Number has not been registered');
     }
     if (empty($this->destinationNumber)) {
         throw new DestinationSMSNumberIsEmptyException('Destination Number has not been registered');
     }
     if (empty($this->message)) {
         throw new MessageIsEmptyException('The Message is empty');
     }
     $data = $this->getMessageData();
     return $this->plivo->send_message($data);
 }
예제 #3
0
<?php

require 'vendor/autoload.php';
use Plivo\RestAPI;
$auth_id = "MAMWYYYZLJNTVLYJMYYJ";
$auth_token = "MWQzZDZkZTU1OTc1OGY5N2IyYTJjYTdiNDIwYmQz";
$p = new RestAPI($auth_id, $auth_token);
// Send a message
$params = array('src' => '7772823928', 'dst' => '+919009472525', 'text' => 'Hi, Message from Plivo');
// Send message
$response = $p->send_message($params);
// Print the response
echo "Response : ";
print_r($response['response']);
// Print the Api ID
echo "<br> Api ID : {$response['response']['api_id']} <br>";
// Print the Message UUID
echo "Message UUID : {$response['response']['message_uuid'][0]} <br>";