[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

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

   1  =============
   2  Sip In
   3  =============
   4  
   5  Getting started with Sip
   6  ==========================
   7  
   8  If you're unfamiliar with SIP, please see the `SIP API Documentation
   9  <https://www.twilio.com/docs/api/rest/sip>`_ on our website.
  10  
  11  Creating a Sip Domain
  12  =========================
  13  
  14  The :class:`Domains <Services_Twilio_Rest_Domains>` resource allows you to
  15  create a new domain. To create a new domain, you'll need to choose a unique
  16  domain that lives under sip.twilio.com. For example, doug.sip.twilio.com.
  17  
  18  .. code-block:: php
  19  
  20      require('/path/to/twilio-php/Services/Twilio.php');
  21  
  22      $client = new Services_Twilio('AC123', '123');
  23      $domain = $client->account->sip->domains->create(
  24        "Doug's Domain", // The FriendlyName for your new domain
  25        "doug.sip.twilio.com", // The sip domain for your new domain
  26        array(
  27          'VoiceUrl' => 'http://example.com/voice',
  28      ));
  29  
  30      echo $domain->sid;
  31  
  32  Creating a new IpAccessControlList
  33  ====================================
  34  
  35  To control access to your new domain, you'll need to explicitly grant access
  36  to individual ip addresses. To do this, you'll first need to create an
  37  :class:`IpAccessControlList <Services_Twilio_Rest_IpAccessControlList>` to hold
  38  the ip addresses you wish to allow.
  39  
  40  .. code-block:: php
  41  
  42      require('/path/to/twilio-php/Services/Twilio.php');
  43  
  44      $client = new Services_Twilio('AC123', '123');
  45      $ip_access_control_list = $client->account->sip->ip_access_control_lists->create(
  46        "Doug's IpAccessControlList", // The FriendlyName for your new ip access control list
  47      );
  48  
  49      echo $ip_access_control_list->sid;
  50  
  51  Adding an IpAddress to an IpAccessControlList
  52  ==============================================
  53  
  54  Now it's time to add an :class:`IpAddress
  55  <Services_Twilio_Rest_IpAddress>` to your new :class:`IpAccessControlList
  56  <Services_Twilio_Rest_IpAccessControlList>`.
  57  
  58  .. code-block:: php
  59  
  60      require('/path/to/twilio-php/Services/Twilio.php');
  61  
  62      $client = new Services_Twilio('AC123', '123');
  63      $ip_address = $client->account->sip->ip_access_control_lists->get('AC123')->ip_addresses->create(
  64        "Doug's IpAddress", // The FriendlyName for this IpAddress 
  65        '127.0.0.1', // The ip address for this IpAddress
  66      );
  67  
  68      echo $ip_address->sid;
  69  
  70  Adding an IpAccessControlList to a Domain
  71  ===========================================
  72  
  73  Once you've created a :class:`Domain <Services_Twilio_Rest_Domain>` and an
  74  :class:`IpAccessControlList <Services_Twilio_Rest_IpAccessControlList>`
  75  you need to associate them. To do this,
  76  create an :class:`IpAccessControlListMapping
  77  <Services_Twilio_Rest_IpAccessControlListMapping>`.
  78  
  79  .. code-block:: php
  80  
  81      require('/path/to/twilio-php/Services/Twilio.php');
  82  
  83      $client = new Services_Twilio('AC123', '123');
  84      $ip_access_control_list_mapping = $client->account->sip->domains->get('SD123')->ip_access_control_list_mappings->create(
  85        'AL123', // The sid of your IpAccessControlList
  86      );
  87  
  88      echo $ip_access_control_list_mapping->sid;


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