API for TwiML Generation

class Services_Twilio_Twiml

Twiml response generator.

Author: Neuman Vong <neuman at ashmoremusic dot com> License: http://creativecommons.org/licenses/MIT/ MIT

__construct($arg = null)

Constructs a Twiml response.

  • $arg (SimpleXmlElement|array) –

    Can be any of

    • the element to wrap
    • attributes to add to the element
    • if null, initialize an empty element named ‘Response’
__call($verb, array $args)

Converts method calls into Twiml verbs.

A basic example:

php> print $this->say('hello');

An example with attributes:

print $this->say('hello', array('voice' => 'woman'));
<Say voice="woman">hello</Say>

You could even just pass in an attributes array, omitting the noun:

print $this->gather(array('timeout' => '20'));
<Gather timeout="20"/>
  • $verb (string) – The Twiml verb.
  • $args (array) –
    • (noun string)
    • (noun string, attributes array)
    • (attributes array)

A SimpleXmlElement

Return type:



Returns the object as XML.

Returns:The response as an XML string
Return type:string