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.

Parameters:
  • $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');
<Say>hello</Say>

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"/>
Parameters:
  • $verb (string) – The Twiml verb.
  • $args (array) –
    • (noun string)
    • (noun string, attributes array)
    • (attributes array)
Returns:

A SimpleXmlElement

Return type:

SimpleXmlElement

__toString()

Returns the object as XML.

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