承接 woenel/laravel-txtbox 相关项目开发

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

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

woenel/laravel-txtbox

最新稳定版本:v2.0.4

Composer 安装命令:

composer require woenel/laravel-txtbox

包简介

TxtBox API for Laravel.

README 文档

README

TxtBox SMS API for Laravel.

Packagist Version Packagist

What is TxtBox

Txtbox lets you send an SMS with a single line of code. No complicated setup, no dealing with telecom protocols and procedures.

For more info, you can visit their website at: https://www.txtbox.com

Requirements

  • PHP: 7.2.x and up or 8.0.x
  • Laravel: 8.x.x or 9.x.x (For Laravel 7.x.x, use version 1.x.x)
  • TxtBox API Key

Installation

Install using Composer

For Laravel 8:
$ composer require woenel/laravel-txtbox

For Laravel 7:
$ composer require woenel/laravel-txtbox "^1.3"

Publish the config file named txtbox.php and set the TxtBox API key.

$ php artisan vendor:publish --provider="Woenel\TxtBox\TxtBoxServiceProvider"

Usage

Send a Message

These are the three methods you can use to send a message:

1. Using facade
use Woenel\TxtBox\Facades\TxtBox;

$result = TxtBox::to('09123456789')->message('Hello World!')->send();

if($result->success) {
  echo $result->message;
} else {
  echo $result->message;
}
2. Instantiating class (chaining)
use Woenel\TxtBox\TxtBox;

$txtbox = new TxtBox;

$result = $txtbox->to('09123456789')->message('Hello World!')->send();

if($result->success) {
  echo $result->message;
} else {
  echo $result->message;
}
3. Instantiating class (one-by-one)
use Woenel\TxtBox\TxtBox;

$txtbox = new TxtBox;

$txtbox->to = '09123456789';
$txtbox->message = 'Hello World!';
$result = $txtbox->send();

if($result->success) {
  echo $result->message;
} else {
  echo $result->message;
}

Success and Failure returns

TxtBox Laravel API returns object-type values.

Success

Message successfully sent to 09XXXXXXXXX
This happens when you successfully sent a message.

{
  "success": true,
  "message": 'Message successfully sent to 09XXXXXXXXX'
}

Failures

Invalid Token
This happens when you did not provide a valid API key. API key can be modified in txtbox.php file under config folder.

{
  "success": false,
  "message": 'Invalid Token'
}

Unprocessable Entity
This happens when you did not enter a value. Number to() and Message message() are both required entities.

{
  "success": false,
  "message": 'Unprocessable Entity',
  "errors": {
    "number": [
      0 => 'The message field is required.'
    ],
    "message": [
      0 => 'The number field is required.'
    ]
  }
}

Insufficient credits. Please buy more credit to use this service.
This happens when you already used all of your SMS credits.

{
  "success": false,
  "message": 'Insufficient credits. Please buy more credit to use this service.'
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-29