承接 tm4b/tm4b-php 相关项目开发

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

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

tm4b/tm4b-php

Composer 安装命令:

composer require tm4b/tm4b-php

包简介

PHP Client for using TM4B's REST API

README 文档

README

Build Status

Sign up for a TM4B account and visit our Developer Api for even more content.

TM4B PHP Client

This is the official PHP library for using the TM4B REST API. This SDK contains methods for easily interacting with the TM4B Messaging API. Below are examples to get you started. For additional examples, please see our official documentation at https://www.tm4b.com/en/sms-api/

Installation

The recommended way to install TM4B PHP is through Composer. Require the tm4b/tm4b-php package:

$ composer require tm4b/tm4b-php

Usage

Basic usage

You should always use Composer's autoloader in your application to automatically load your dependencies. All examples below assumes you've already included this in your file:

require 'vendor/autoload.php';

Initialize your TM4B Client with your TM4B API Key:

<?php

require 'vendor/autoload.php';

$msgClient = \Tm4b\Rest\Client::create([
    'apiKey' => 'TM4B_API_KEY'
]);

Quick Start

Here is a quick example:

POST /api/rest/v1/sms

<?php

require 'vendor/autoload.php';

$msgClient = \Tm4b\Rest\Client::create([
    'apiKey' => 'TM4B_API_KEY'
]);

try {
    $response = $msgClient->messages()->send([
        'destination_address' => '+441234567890',
        'source_address'      => 'master',
        'content'             => 'There is a civil war between the Galactic Empire and a Rebel Alliance.'
    ]);
    print_r($response);
} catch (\Tm4b\Exception\HttpClientException $e) {
    print_r($e->getResponseBody());
}

Examples

Bulk SMS

Let's send the same SMS to 2 recipients.

<?php

require 'vendor/autoload.php';

$msgClient = \Tm4b\Rest\Client::create([
    'apiKey' => 'TM4B_API_KEY'
]);

$response = $msgClient->messages()->send([
    [
        'destination_address' => '+447711961111',
        'source_address'      => 'GeorgeLucas',
        'content'             => 'There is a civil war between the Galactic Empire and a Rebel Alliance.'
    ],
    [
        'destination_address' => '+97150349030',
        'source_address'      => 'GeorgeLucas',
        'content'             => 'There is a civil war between the Galactic Empire and a Rebel Alliance.'
    ]
]);

Sandbox

<?php

require 'vendor/autoload.php';

$msgClient = \Tm4b\Rest\Client::create([
    'apiKey' => 'TM4B_API_KEY'
]);

$msgClient->setSandbox(true);
$response = $msgClient->messages()->send([
    [
        'destination_address' => '+447711961111',
        'source_address'      => 'GeorgeLucas',
        'content'             => 'There is a civil war between the Galactic Empire and a Rebel Alliance.'
    ]
]);

Account

<?php

require 'vendor/autoload.php';

$msgClient = \Tm4b\Rest\Client::create([
    'apiKey' => 'TM4B_API_KEY'
]);
$response = $msgClient->account()->describe();

General Usage

<?php

require 'vendor/autoload.php';

$msgClient = \Tm4b\Rest\Client::create([
    'apiKey' => 'TM4B_API_KEY'
]);

try {
    $response = $msgClient->get('/account');
    $data = $msgClient->hydrate($response, null);
    print_r($data);
} catch (\Http\Client\Exception $e) {
    print_r($e->getTraceAsString());
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-01-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固