定制 cloudonix/cxml-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cloudonix/cxml-php

Composer 安装命令:

composer require cloudonix/cxml-php

包简介

A PHP Wrapper library for Cloudonix's CXML language

README 文档

README

Contributors Packagist

Documentation

The documentation for the Cloudonix CXML markup language can be found here.

The PHP library documentation can be found here

Supported PHP Versions

This library supports the following PHP versions:

  • PHP 8.0
  • PHP 8.1
  • PHP 8.2
  • PHP 8.3

Installation

You can install cxml-php via composer or by downloading the source.

composer require cloudonix/cxml-php

Test your installation

Here is a sample PHP script that will generate a CXML Voice Application document, using the library:

<?php

require(__DIR__ . "/vendor/autoload.php");

use Cloudonix\CXML\Response;

$responder = new Response();
$responder->dial("12127773456");
$responder->redirect("https://example.com/script.php");

$responder->gather([
    (new Response())->play("https://example.com/playfile.mp3")->attributes(["loop" => 3]),
    (new Response())->pause()->attributes(["length" => 5]),
])->attributes(["action" => "https://example.com/script.php"]);

$responder->hangup();

echo $responder;

Copy&Paste the above script to a new file, and execute it from the command line, the following should be the result:

$ php cxmlResponder.php 
<Response>
  <DIAL>12127773456</DIAL>
  <REDIRECT>https://example.com/script.php</REDIRECT>
  <GATHER action="https://example.com/script.php">
    <PLAY loop="3">https://example.com/playfile.mp3</PLAY>
    <PAUSE length="5" />
  </GATHER>
  <HANGUP />
</Response>

Usage

Create a CXML Document Response with a <PLAY> and <HANGUP>

<?php

require(__DIR__ . "/vendor/autoload.php");

use Cloudonix\CXML\Response;

$responder = new Response();
$responder
    ->play("https://example.com/playfile.mp3")
    ->attributes([
        "loop" => 3,
        "statusCallback" => "https://example.com/statusCallback"
    ]);
$responder->hangup();

echo $responder;

Expected result:

<Response>
  <PLAY loop="3" statusCallback="https://example.com/statusCallback">https://example.com/playfile.mp3</PLAY>
  <HANGUP />
</Response>

Create a CXML Document Response with a <GATHER>, <PLAY>, <PAUSE> and <HANGUP>

<?php

require(__DIR__ . "/vendor/autoload.php");

use Cloudonix\CXML\Response;

$responder = new Response();
$responder->gather([
    (new Response())->play("https://example.com/playfile.mp3")->attributes(["loop" => 3]),
    (new Response())->pause()->attributes(["length" => 5]),
])->attributes(["action" => "https://example.com/script.php"]);
$responder->hangup();

echo $responder;

Expected result:

<Response>
  <GATHER action="https://example.com/script.php">
    <PLAY loop="3">https://example.com/playfile.mp3</PLAY>
    <PAUSE length="5" />
  </GATHER>
  <HANGUP />
</Response>

Getting help

If you need help installing or using the library, please check the Cloudonix Developers Website first.

If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固