Get Started

Twilio Client for iOS Quickstart Tutorial

Set Up Your Twilio App

Wondering what actually happens when you connect using your app, and why you keep hearing that same welcome message? The key to this mystery is in this line in your PHP file:

$capability->allowClientOutgoing($appSid, array(), $clientName);

This creates a security token that tells your device which Twilio Application it will connect to. Applications are just references to TwiML URLs that are fetched when a connection is established from a device, a browser, or a phone. If you are not familiar with TwiML, we suggest you head over to the Twilio Markup Language Quickstart.

The string starting with 'AP' is an ApplicationSid. The default one above is a demo app created by Twilio that serves up a very simple TwiML document that uses <Say> to read a greeting.

Let's build a simple application in PHP to serve TwiML from your web host. Create a new file called hello-client-monkey-twiml.php on your server and paste the following code into that file:

hello-client-monkey-twiml.php
<?php header('Content-type: text/xml'); ?>
<Response>
    <Say>Welcome to Twilio Client!</Say>
</Response>

Assuming your web server is at companyfoo.com, try loading up your new PHP script: http://companyfoo.com/hello-client-monkey-twiml.php in your browser. All set?

Now we're ready to create the new application in the Apps Tab of the Account Dashboard. This is where you can see all your current Twilio Applications and create new ones. Select 'Add Application' and complete the form with the following information:

  • Name - the name of your application. Choose whatever you want.
  • Description - just something that describes your application a little better.
  • Voice Url - points to your web host serving some TwiML. In our case, it should point to the PHP file we created above: http://companyfoo.com/hello-client-monkey-twiml.php.

Click SAVE to create your app. Now, copy the newly created ApplicationSid and paste it into the token generation code at the top of the client script we created before:

$token->allowClientOutgoing('APXXXXXXXXXXXXXXXXXXXXXXXXX'); // Your application sid

If you press the Dial button again, you should now be hearing your very own welcome message!

Sweet. Now, what if you want to pass variables from your iOS app to the script running on the server?


Next: Passing Parameters to your Application »