承接 kureikain/bandwidth-alpaca 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

kureikain/bandwidth-alpaca

Composer 安装命令:

composer require kureikain/bandwidth-alpaca

包简介

Bandwidth API library client for PHP

README 文档

README

Bandwidth API library client for PHP

This library is generated by alpaca

Installation

Make sure you have composer installed.

Add the following to your composer.json

{
    "require": {
        "kureikain/bandwidth-alpaca": "*"
    }
}

Update your dependencies

$ php composer.phar update

This package follows the PSR-0 convention names for its classes, which means you can easily integrate these classes loading in your own autoloader.

Versions

Works with [ 5.4 / 5.5 ]

Usage

<?php

// This file is generated by Composer
require_once 'vendor/autoload.php';

// Then we instantiate a client (as shown below)

Build a client

Using this api without authentication gives an error

Basic authentication
$auth = array('username' => 'pksunkara', 'password' => 'password');

$client = new Bandwidth\Client($auth, $clientOptions);
Authorization header token
$client = new Bandwidth\Client('1a2b3', $clientOptions);

Client Options

The following options are available while instantiating a client:

  • base: Base url for the api
  • api_version: Default version of the api (to be used in url)
  • user_agent: Default user-agent for all requests
  • headers: Default headers for all requests
  • request_type: Default format of the request body

Response information

All the callbacks provided to an api call will receive the response as shown below

$response = $client->klass('args')->method('args', $methodOptions);

$response->code;
// >>> 200

$response->headers;
// >>> array('x-server' => 'apache')
JSON response

When the response sent by server is json, it is decoded into an array

$response->body;
// >>> array('user' => 'pksunkara')

Method Options

The following options are available while calling a method of an api:

  • api_version: Version of the api (to be used in url)
  • headers: Headers for the request
  • query: Query parameters for the url
  • body: Body of the request
  • request_type: Format of the request body

Request body information

Set request_type in options to modify the body accordingly

RAW request

When the value is set to raw, don't modify the body at all.

$body = 'username=pksunkara';
// >>> 'username=pksunkara'
FORM request

When the value is set to form, urlencode the body.

$body = array('user' => 'pksunkara');
// >>> 'user=pksunkara'
JSON request

When the value is set to json, JSON encode the body.

$body = array('user' => 'pksunkara');
// >>> '{"user": "pksunkara"}'

account information api

Retrieve current balance, transaction list, account type and all elements related to your platform account.

The following arguments are required:

  • user_id: user_id of account which is doing API call
$account = $client->account("u-account_id_in_bandwidth");
Get information about your account (GET /users/:user_id/account)

Get information about your account: balance, accountType.

$response = $account->show($options);
Get a list of the transactions made to your account (GET /users/:user_id/account/transactions)

Get the transactions from the user's Account..

$response = $account->transactions($options);

message resources api

Lets you send SMS text messages and view messages that were previously sent or received

The following arguments are required:

  • user_id: user_id of account which is doing API call
$messages = $client->messages("u-account_id_in_bandwidth");
Get a list of previous messages that were sent or received (GET /users/:user_id/messages)

Get a list of previous messages that were sent or received

$response = $messages->fetch($options);
Send text messages (POST /users/:user_id/messages)

Send text messages

$response = $messages->create($options);
Read a message (GET /users/:user_id/messages/:id)

Get information about a message that was sent or received

The following arguments are required:

  • id: message id
$response = $messages->show("111111", $options);

This resource provides a CNAM number info api

CNAM is an acronym which stands for Caller ID Name. CNAM can be used to display the calling party's name alongside the phone number, to help users easily identify a caller. CNAM API allows the user to get the CNAM information of a particular number

The following arguments are required:

  • number: phone number to get the info
$numberInfo = $client->numberInfo("14084442222 //or 408444222 is ok");
Get the CNAM of the number (GET /phoneNumbers/numberInfo/:number)

Get the CNAM of the number

$response = $numberInfo->show($options);

User Errors api

The User Errors resource lets you see information about errors that happened in your API calls and during applications callbacks. This error information can be very helpful when you're debugging an application. Because error information can be large, and errors in the distant past are less useful than new ones, Bandwidth API limits the number of user errors it keeps.

$errors = $client->errors("u-account_id_in_bandwidth");
Gets information about one user error (GET /users/:user_id/errors/:error_id)

Gets information about one user error

The following arguments are required:

  • error_id: Error ID
$response = $errors->show("error_id", $options);
Gets all the user errors for a user (GET /users/:user_id/errors)

Gets all the user errors for a user

$response = $errors->fetch($options);

Find and Buy available numbers api

The Available Numbers resource lets you search for numbers that are available for use with your application.

$availableNumbers = $client->availableNumbers("u-account_id_in_bandwidth");
Search an available local number (GET /availableNumbers/local)

Search and available local number that we can buy

The following arguments are required:

$response = $availableNumbers->searchLocal("San Jose", "CA", 95111, 408, "4083", true, 10, "*2%3F9", $options);
Buy a local number (POST /availableNumbers/local)

Search and order available local numbers

The following arguments are required:

$response = $availableNumbers->createLocal("San Jose", "CA", 95111, 408, "4083", true, 10, $options);
Search for available toll free numbers (GET /availableNumbers/tollFree)

Search for available toll free numbers

$response = $availableNumbers->searchTollFree($options);
Search and order available toll free numbers (POST /availableNumbers/tollFree)

Search and order available toll free numbers

$response = $availableNumbers->createTollFree($options);

Manipulation calls api

The Calls resource lets you make phone calls and view information about previous inbound and outbound calls.

The following arguments are required:

  • user_id: user_id of account which is doing API call
$calls = $client->calls("u-account_id_in_bandwidth");
Send DTMF (POST /users/:user_id/calls/:call_id/dtmf)

Send DTMF to a call

The following arguments are required:

  • call_id: call id
$response = $calls->dtmf("111111", $options);
Retrieve all recordings related to the call (GET /users/:user_id/calls/:call_id/recordings)

Retrieve all recordings related to the call

The following arguments are required:

  • call_id: call id
$response = $calls->recordings("111111", $options);
Update the gather DTMF (Stop Gather) (POST /users/:user_id/calls/:call_id/gather/:gather_id)

Update the gather DTMF (Stop Gather)

The following arguments are required:

  • call_id: call id
  • gather_id: gather id
$response = $calls->updateGather("111111", "222222", $options);
Gets a list of active and historic calls you made or received (GET /users/:user_id/calls)

Gets a list of active and historic calls you made or received

$response = $calls->fetch($options);
Makes a phone call. (POST /users/:user_id/calls)

Makes a phone call.

The following arguments are required:

  • to: number which we call to
  • from: number which we call from
$response = $calls->create("4081112244", "6501112222", $options);
Gets information about an active or completed call (GET /users/:user_id/calls/:call_id)

Gets information about an active or completed call. No query parameters are supported

The following arguments are required:

  • call_id: call id
$response = $calls->show("111111", $options);
Changes properties of an active phone call (POST /users/:user_id/calls/:call_id)

Changes properties of an active phone call

The following arguments are required:

  • call_id: call id
$response = $calls->update("111111", $options);
Play an audio or speak a sentence in a call (POST /users/:user_id/calls/:call_id/audio)

Play an audio or speak a sentence in a call

The following arguments are required:

  • call_id: call id
$response = $calls->audio("111111", $options);
Gather the DTMF digits pressed (POST /users/:user_id/calls/:call_id/gather)

Gather the DTMF digits pressed by the user.

The following arguments are required:

  • call_id: call id
$response = $calls->createGather("111111", $options);
Get the gather DTMF parameters and results (GET /users/:user_id/calls/:call_id/gather/:gather_id)

Get the gather DTMF parameters and results

The following arguments are required:

  • call_id: call id
  • gather_id: gather id
$response = $calls->gather("111111", "222222", $options);

The Phone Numbers resource lets you get phone numbers for use with your programs and manage numbers you already have api

The Phone Numbers resource lets you get phone numbers for use with your programs and manage numbers you already have

The following arguments are required:

  • user_id: user_id of account which is doing API call
$phoneNumbers = $client->phoneNumbers("u-account_id_in_bandwidth");
Gets a list of your numbers. (GET /users/:user_id/phoneNumbers)

Gets a list of your numbers.

$response = $phoneNumbers->fetch($options);
Allocates a number so you can use it to make and receive calls and send and receive messages (POST /users/:user_id/phoneNumbers)

Allocates a number so you can use it to make and receive calls and send and receive messages

The following arguments are required:

  • number: An available telephone number you want to use (must be in E.164 format, like +19195551212)
$response = $phoneNumbers->create("+19195551212", "u-hdsadasdsad7-sample-app-id", "Customer Name", "Default NC Number", $options);
Gets information about one of your numbers using the number's ID (GET /users/:user_id/phoneNumbers/:number_id)

Gets information about one of your numbers using the number's ID

The following arguments are required:

  • number_id: Number ID inside Bandwidth system
$response = $phoneNumbers->showById("sample_number_id", $options);
Gets information about one of your numbers using the number itself (GET /users/:user_id/phoneNumbers/:number)

Gets information about one of your numbers using the E.164 number string, like +19195551212. Remember to URL encode the plus sign prefix

The following arguments are required:

  • number: phone number
$response = $phoneNumbers->showByNumber("+14083872696", $options);
Make changes to a number you have (POST /users/:user_id/phoneNumbers/:number_id)

Makes changes to a number you have. POST a new JSON representation with the property values you desire to the URL that you got back in the "Location" header when you first allocated it. Properties you don't send will remain unchanged.

The following arguments are required:

  • number_id: id of phone number in twilio system. The ID of a number can be found by showByNumber
$response = $phoneNumbers->update("n-111111", $options);
Remove a number from your account (DELETE /users/:user_id/phoneNumbers/:number_id)

emoves a number from your account so you can no longer make or receive calls, or send or receive messages with it. When you remove a number from your account, it will not immediately become available for re-use, so be careful.

The following arguments are required:

  • number_id: id of phone number in twilio system. The ID of a number can be found by showByNumber
$response = $phoneNumbers->destroy("n-111111", $options);

Conference resouce api

The Conference resource allows you create conferences, add members to it, play audio, speak text, mute/unmute members, hold/unhold members and other things related to conferencing.

The following arguments are required:

  • user_id: user_id of account which is doing API call
$conferences = $client->conferences("u-account_id_in_bandwidth");
Create a conference. (POST /users/:user_id/conferences)

Creates a conference.

The following arguments are required:

  • from: the phone number which conferences will be created on it
$response = $conferences->create("+14081112323", $options);
Add a member to a conference. (POST /users/:user_id/conferences/:conference_id/members)

Add a member to a conference.

The following arguments are required:

  • conference_id: Conference ID
  • callId: Call ID to join into conference
$response = $conferences->createMember("conf-2jir46wjc5puqpiwthqma5y", "c-m2vrf4lpryjlvwgvsnf6ery", $options);
Play an audio/speak a sentence in the conference. (POST /users/:user_id/conferences/:conference_id/audio)

Play an audio/speak a sentence in the conference.

The following arguments are required:

  • conference_id: Conference ID
$response = $conferences->audio("conf-2jir46wjc5puqpiwthqma5y", $options);

Bridges resource api

Bridges resource. Bridge two calls allowing two way audio between them.

The following arguments are required:

  • user_id: user_id of account which is doing API call
$bridges = $client->bridges("u-account_id_in_bandwidth");
Create a bridge (POST /users/:user_id/bridges)

Create a bridge

The following arguments are required:

$response = $bridges->create("true", "c-m2vrf4lpryjlvwgvsnf6ery", $options);
Play an audio or speak a sentence in a bridge (POST /users/:user_id/bridges/:bridge_id/audio)

Play an audio or speak a sentence in a bridge

The following arguments are required:

  • bridge_id: Bridge ID
$response = $bridges->audio("b_bridge_id_in_bandwidth", $options);
Get the list of calls that are on the bridge (GET /users/:user_id/bridges/:bridge_id/calls)

Get the list of calls that are on the bridge

The following arguments are required:

  • bridge_id: Bridge ID
$response = $bridges->listCall("b_bridge_id_in_bandwidth", $options);
Change calls in a bridge and bridge/unbridge the audio (POST /users/:user_id/bridges/:bridge_id)

Change calls in a bridge and bridge/unbridge the audio

The following arguments are required:

  • bridge_id: Bridge ID
$response = $bridges->update("b_bridge_id_in_bandwidth", $options);

Retrieve call recordings, filtering by Id, user and/or calls api

Retrieve call recordings, filtering by Id, user and/or calls. Learn how record a Call The recording information retrieved by GET method contains only textual data related to call recording as described on Properties section. To properly work with recorded media content such as download and removal of media file, please access Media documentation

$recordings = $client->recordings("u-account_id_in_bandwidth");
Retrieve a specific call recording information, identified by recordingId (GET /users/:user_id/recordings/:recording_id)

Retrieve a specific call recording information, identified by recordingId

The following arguments are required:

  • recording_id: Recording ID
$response = $recordings->show("r_recoridng_id_in_bandwidth", $options);
List a user's call recordings (GET /users/:user_id/recordings)

List a user's call recordings

$response = $recordings->fetch($options);

Contributors

Here is a list of Contributors

TODO

License

MIT

Bug Reports

Report here.

Contact

kureikain (kurei@axcoto.com)

kureikain/bandwidth-alpaca 适用场景与选型建议

kureikain/bandwidth-alpaca 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 543 次下载、GitHub Stars 达 3, 最近一次更新时间为 2014 年 09 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「api」 「client」 「library」 「alpaca」 「bandwidth」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 kureikain/bandwidth-alpaca 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 kureikain/bandwidth-alpaca 我们能提供哪些服务?
定制开发 / 二次开发

基于 kureikain/bandwidth-alpaca 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-09-03