public function send($to, $message)
 {
     require_once '_plivo.php';
     $p = new RestAPI($this->getAccount(), $this->getPassword());
     $params = array('src' => str_replace('+', '', $this->getFrom()), 'dst' => $to, 'text' => $message, 'type' => 'sms');
     $response = $p->send_message($params);
     $tmp = array_values($response);
     if (array_shift($tmp) != "202") {
         throw new Exception('Plivo: Please ensure that From number is a valid and sms feature enabled Plivo DID number');
     }
 }
示例#2
0
<?php

require_once '../plivo.php';
$auth_id = "Your AUTH_ID";
$auth_token = "Your AUTH_TOKEN";
$p = new RestAPI($auth_id, $auth_token);
// Send a message
$params = array('src' => '1111111111', 'dst' => '2222222222', 'text' => 'This randomly generated text can be used in your layout (webdesign , websites, books, posters ... ) for free. This text is entirely free of law. Feel free to link to this site by using the image below or by making a simple text link');
$response = $p->send_message($params);
// Print the response
print_r($response['response']);
// Print the Message UUID
$uuid = $response['response']['message_uuid'][0];
print $uuid;
$params = array('record_id' => $uuid);
// To get the SMS split units
$r = new RestAPI($auth_id, $auth_token);
$response = $r->get_message($params);
$units = $response['response']['units'];
// Print the response
print "Your sms was split into : {$units} units";
?>

<!--
Sample Output
( 
    [api_id] => dd294730-a262-11e4-b153-22000abcaa64 
    [message] => message(s) queued 
    [message_uuid] => Array ( [0] => dd4ba604-a262-11e4-a6e4-22000afa12b0 ) 
)
示例#3
0
文件: Plivo.php 项目: popas/plivo
 /**
  * send sms and return the status .
  *
  * @param  $auth_id, $auth_token 
  * @return response status
  */
 private function sendMessage($auth_id, $auth_token)
 {
     // Set message parameters
     $params = array('src' => $this->src, 'dst' => $this->dest, 'text' => $this->txt, 'url' => $this->returnBackUrl, 'method' => 'POST');
     $sendsms = new \RestAPI($this->auth_id, $this->auth_token);
     $response = $sendsms->send_message($params);
     if ($sendsms->send_message($params)) {
         return "Message sent successfully";
     } else {
         return "Message sending failed";
     }
 }