synesisinc / tropo-webapi-php
为 Tropo PHP Web API 带来新生
dev-master / 2.0.x-dev
2017-06-08 17:08 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-14 19:20:10 UTC
README
TropoPHP 是一组用于与 Tropo 的云通信服务 打交道的 PHP 类。Tropo 允许开发人员使用 Web 技术创建在电话、即时消息、短信和 Twitter 上运行的应用程序。此库通过 JSON 与 Tropo 通信。
要求
- PHP 5.3.0 或更高版本
- PHP 警告已禁用(建议在生产环境中禁用所有错误报告)
安装
-
通过 Composer
- 稳定版:
composer require synesisinc/tropo-webapi-php
- 开发版:
composer require synesisinc/tropo-webapi-php 2.0.*@dev
- 稳定版:
-
或者,从以下 GitHub 项目下载/克隆: https://github.com/synesisinc/tropo-webapi-php.git 并执行
require /path/to/tropo-webapi-php/autoload.php
使用方法
接听电话,说些话,然后挂断。
<?php
$tropo = new \Tropo\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
$tropo = new \Tropo\Tropo();
// Ask the user a question
$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();