camcima / tropo-webapi-php
重构的 Tropo PHP 5 包
dev-master
2013-02-07 19:19 UTC
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2024-09-07 05:01:40 UTC
README
TropoPHP 是一套用于与 Tropo 的云通信服务 打交道的 PHP 类。Tropo 允许开发者使用网络技术创建在电话、即时消息、短信和 Twitter 上运行的应用程序。此库通过 JSON 与 Tropo 通信。
要求
- PHP 5.3.0 或更高版本
- PHP 警告已禁用(建议在生产环境中禁用所有错误报告)
使用方法
接听电话,说些话,然后挂断。
<?php
require 'tropo.class.php';
$tropo = new Tropo();
// Use Tropo's text to speech to say a phrase.
$tropo->say('Yes, Tropo is this easy.');
// Render the JSON back to Tropo.
$tropo->renderJSON();
?>
请求输入。
<?php
require 'tropo.class.php';
$tropo = new Tropo();
$tropo->ask('What is your favorite programming language?', array(
'choices'=>'PHP, Ruby(Ruby, Rails, Ruby on Rails), Python, Java(Groovy, Java), Perl',
'event'=> array(
'nomatch' => 'Never heard of it.',
'timeout' => 'Speak up!',
)
));
// Tell Tropo how to continue if a successful choice was made
$tropo->on(array('event' => 'continue', 'say'=> 'Fantastic! I love that, too!'));
// Render the JSON back to Tropo
$tropo->renderJSON();
?>