gecatalin / telapi-php
此包的最新版本(dev-master)没有可用的许可信息。
dev-master
2013-08-07 16:03 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-24 04:20:09 UTC
README
此PHP库是一个开源工具,旨在简化与TelAPI电话平台的交互。TelAPI让在应用程序中添加语音和短信变得有趣且简单。
有关此库的完整文档,请访问:http://telapi.github.com/telapi-php
有关TelAPI的更多信息,请访问:telapi.com/features或telapi.com/docs
安装
通过Pear
目前我们不支持PEAR包,但将在不久的将来支持!
需要PHP 5.2+(推荐5.3+)
通过GitHub克隆
访问终端并运行以下代码
$ cd ~ $ git clone https://github.com/TelAPI/telapi-php.git $ cd telapi-php
通过下载
步骤1
下载.zip文件。
步骤2
下载.zip文件完成后,将其解压,并按照下面的示例开始使用。
用法
REST
发送短信示例
<?php require_once '../library/TelApi.php'; // Set up your TelAPI credentials $telapi = TelApi::getInstance(); $telapi -> setOptions(array( 'account_sid' => '{AccountSid}', 'auth_token' => '{AuthToken}', )); // Send the SMS $sms_message = $telapi->create('sms_messages', array( 'From' => '+12223334444', 'To' => '+15550001212', 'Body' => "This is an SMS message sent from the TelAPI PHP wrapper! Easy as 1, 2, 3!" )); print_r($sms_message);
InboundXML
InboundXML是一种XML方言,它允许您控制电话通话流程。有关更多信息,请访问TelAPI InboundXML文档
示例
<?php require_once('library/TelApi/InboundXML.php'); $inbound_xml = new TelApi_InboundXML(); $inbound_xml->say('Welcome to TelAPI. This is a sample InboundXML document.', array('voice' => 'man')); echo $inbound_xml;
将呈现
<?xml version="1.0" encoding="UTF-8"?> <Response> <Say voice="man">Welcome to TelAPI. This is a sample InboundXML document.</Say> </Response>
只需将那个PHP文件托管在某处,在你TelAPI账户仪表板中购买一个电话号码,并将该PHP页面的URL分配给你的新号码。每次你拨打该号码时,此页面生成的InboundXML将被执行,你将听到我们的文本到语音引擎说欢迎。