telapi/telapi-php

此包的最新版本(dev-master)没有可用的许可证信息。

dev-master 2015-01-24 20:49 UTC

This package is auto-updated.

Last update: 2024-09-29 03:31:05 UTC


README

这个PHP库是一个开源工具,旨在简化与TelAPI电话平台的交互。TelAPI使向应用添加语音和短信变得有趣且简单。

有关此库的完整文档,请访问:http://telapi.github.com/telapi-php

有关TelAPI的更多信息,请访问:telapi.com/featurestelapi.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

TelAPI REST API文档

发送短信示例
<?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将被执行,您将听到我们的语音合成器说出欢迎词。

文档

http://telapi.github.com/telapi-php