[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/externals/twilio-php/docs/usage/rest/ -> sms-messages.rst (source)

   1  =============
   2  SMS Messages
   3  =============
   4  
   5  Sending a SMS Message
   6  =====================
   7  
   8  
   9  The :php:class:`Services_Twilio_Rest_SmsMessages` resource allows you to send
  10  outgoing text messages.
  11  
  12  .. code-block:: php
  13  
  14      require('/path/to/twilio-php/Services/Twilio.php');
  15  
  16      $client = new Services_Twilio('AC123', '123');
  17      $message = $client->account->sms_messages->create(
  18        '+14085551234', // From a Twilio number in your account
  19        '+12125551234', // Text any number
  20        "Hello monkey!"
  21      );
  22  
  23      print $message->sid;
  24  
  25  Listing SMS Messages
  26  ====================
  27  
  28  It's easy to iterate over your SMS messages.
  29  
  30  .. code-block:: php
  31  
  32      $client = new Services_Twilio('AC123', '123');
  33      foreach ($client->account->sms_messages as $message) {
  34          echo "From: {$message->from}\nTo: {$message->to}\nBody: " . $message->body;
  35      }
  36  
  37  Filtering SMS Messages
  38  ======================
  39  
  40  Let's say you want to find all of the SMS messages that have been sent from
  41  a particular number. You can do so by constructing an iterator explicitly:
  42  
  43  .. code-block:: php
  44  
  45      $client = new Services_Twilio('AC123', '123');
  46      foreach ($client->account->sms_messages->getIterator(0, 50, array(
  47          'From' => '+14105551234',
  48      )) as $message) {
  49          echo "From: {$message->from}\nTo: {$message->to}\nBody: " . $message->body;
  50      }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1