Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add usage examples to calls, SMS

  • Loading branch information...
commit 58a825743a30040da6a0fa6404b6d0cab30df404 1 parent 73719fd
Kevin Burke authored
Showing with 76 additions and 1 deletion.
  1. +49 −1 docs/usage/rest/calls.rst
  2. +27 −0 docs/usage/rest/sms-messages.rst
View
50 docs/usage/rest/calls.rst
@@ -18,10 +18,58 @@ The :class:`Calls` resource allows you to make outgoing calls:
print $call->length;
print $call->sid;
+Adding Extra Call Parameters
+============================
+
+Add extra parameters, like a `StatusCallback` when the call ends, like this:
+
+.. code-block:: php
+
+ $client = new Services_Twilio('AC123', '123');
+ $call = $client->account->calls->create(
+ '9991231234', // From this number
+ '8881231234', // Call this number
+ 'http://foo.com/call.xml',
+ array(
+ 'StatusCallback' => 'http://foo.com/callback',
+ 'StatusCallbackMethod' => 'GET'
+ )
+ );
+
+A full list of parameters can be found `here
+<http://www.twilio.com/docs/api/rest/making-calls#post-parameters-optional>`_.
+
+Listing Calls
+=============
+
+It's easy to iterate over your list of calls.
+
+.. code-block:: php
+
+ $client = new Services_Twilio('AC123', '123');
+ foreach ($client->account->calls as $call) {
+ echo "From: {$call->from}\nTo: {$call->to}\nSid: {$call->sid}\n\n";
+ }
+
+Filtering Calls
+======================
+
+Let's say you want to find all of the calls that have been sent from
+a particular number. You can do so by constructing an iterator explicitly:
+
+.. code-block:: php
+
+ $client = new Services_Twilio('AC123', '123');
+ foreach ($client->account->calls->getIterator(0, 50, array(
+ 'From' => '+14105551234',
+ ) as $call) {
+ echo "From: {$call->from}\nTo: {$call->to}\nSid: {$call->sid}\n\n";
+ }
+
Accessing Resources from a Specific Call
========================================
-The :class:`Call` resource has some sub resources you can access, such as
+The :class:`Call` resource has some subresources you can access, such as
notifications and recordings. If you have already have a :class:`Call`
resource, they are easy to get.:
View
27 docs/usage/rest/sms-messages.rst
@@ -19,3 +19,30 @@ The :class:`SmsMessages` resource allows you to send outgoing text messages.
);
print $message->sid;
+
+Listing SMS Messages
+====================
+
+It's easy to iterate over your SMS messages.
+
+.. code-block:: php
+
+ $client = new Services_Twilio('AC123', '123');
+ foreach ($client->account->sms_messages as $message) {
+ echo "From: {$message->from}\nTo: {$message->to}\nBody: " . $message->body;
+ }
+
+Filtering SMS Messages
+======================
+
+Let's say you want to find all of the SMS messages that have been sent from
+a particular number. You can do so by constructing an iterator explicitly:
+
+.. code-block:: php
+
+ $client = new Services_Twilio('AC123', '123');
+ foreach ($client->account->sms_messages->getIterator(0, 50, array(
+ 'From' => '+14105551234',
+ ) as $message) {
+ echo "From: {$message->from}\nTo: {$message->to}\nBody: " . $message->body;
+ }
Please sign in to comment.
Something went wrong with that request. Please try again.