TwiML: PHP Quickstart Tutorial
TwiML Quickstart: Hello Monkey
Let's walk through creating your first application, Hello Monkey. We'll use
PHP to construct this example, but almost any web development language
could be used.
- To begin, you'll need a Twilio inbound phone number. You can use a free
Twilio trial account or upgrade your account and get your own dedicated
- You will also need a web host that lets you host PHP applications. There
are lots of web hosting services that with host your PHP application for a few
dollars a month.
You can download the (minimal) code used in this example if you want:
Hello Monkey, v1.0
- Let's say your web server answers HTTP requests at companyfoo.com.
Create a file called hello-monkey.php in the document root. The URL should be
http://companyfoo.com/hello-monkey.php and will be the initial voice URL for
your phone number.
- Browse to the Phone Numbers page in your account on the Twilio website.
If you don't already have a Twilio phone number, you can purchase your own
phone number using the "Buy a Number" button on the right hand side of the
page. Click the "Edit" link next to the phone number you would like to use.
Next, check the "Voice" box, and paste the URL of your hello-monkey file (e.g.
http://companyfoo.com/hello-monkey.php) in the "URL" box. Hit save and this
phone number will now point to your new hello monkey code.
- Now, open up the hello-monkey.php file on your web server. Let's start with
this basic php example code:
Now, pick up your mobile or landline phone and dial the number of application.
Twilio will now fetch your URL, http://companyfoo.com/hello-monkey.php in our
case, and execute the XML instructions above. First, it will Say 'hello monkey'
and then it will hang up because there are no more instructions.
Next: Greet caller by name »