定制 unimtx/uni-sdk 二次开发

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

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

unimtx/uni-sdk

最新稳定版本:v0.3.0

Composer 安装命令:

composer require unimtx/uni-sdk

包简介

The official Unimatrix SDK for PHP.

README 文档

README

Packagist Release GitHub license

The Unimatrix PHP SDK provides convenient access to integrate communication capabilities into your PHP applications using the Unimatrix HTTP API. The SDK provides support for sending SMS, 2FA verification, and phone number lookup.

Getting started

Before you begin, you need an Unimatrix account. If you don't have one yet, you can sign up for an Unimatrix account and get free credits to get you started.

Documentation

Check out the documentation at unimtx.com/docs for a quick overview.

Installation

Using Composer is the recommended way to install the Unimatrix SDK for PHP, which is available on Packagist.

Run the following command to add unimtx/uni-sdk as a dependency to your project:

composer require unimtx/uni-sdk

Usage

The following example shows how to use the Unimatrix PHP SDK to interact with Unimatrix services.

Initialize a client

use Uni\UniClient;

$client = new UniClient([
  'accessKeyId' => 'your access key id',
  'accessKeySecret' => 'your access key secret'
]);

or you can configure your credentials by environment variables:

export UNIMTX_ACCESS_KEY_ID=your_access_key_id
export UNIMTX_ACCESS_KEY_SECRET=your_access_key_secret

Send SMS

Send a text message to a single recipient.

use Uni\UniClient;
use Uni\UniException;

$client = new UniClient();

try {
  $resp = $client->messages->send([
    'to' => '+1206880xxxx', // in E.164 format
    'text' => 'Your verification code is 2048.'
  ]);
  var_dump($resp->data);
} catch (UniException $e) {
  print_r($e);
}

Send verification code

Send a one-time passcode (OTP) to a recipient. The following example will send a automatically generated verification code to the user.

use Uni\UniClient;
use Uni\UniException;

$client = new UniClient();

$resp = $client->otp->send([
  'to' => '+1206880xxxx'
]);
var_dump($resp->data);

Check verification code

Verify the one-time passcode (OTP) that a user provided. The following example will check whether the user-provided verification code is correct.

use Uni\UniClient;
use Uni\UniException;

$client = new UniClient();

$resp = $client->otp->verify([
  'to' => '+1206880xxxx',
  'code' => '123456' // the code user provided
]);
var_dump($resp->valid);

Reference

Other Unimatrix SDKs

To find Unimatrix SDKs in other programming languages, check out the list below:

License

This library is released under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-16