hinet/sms-laravel

Laravel短信API网关接口

0.2.3 2016-07-27 05:52 UTC

README

SMS

Latest Stable Version Total Downloads License

Laravel 5.*短信网关接口

列表

安装

Composer

在终端运行 composer命令安装.

composer require hinet/sms-laravel

在Laravel中配置

打开 config/app.php, 找到 providers 添加 SMSServiceProvider 到数组中.

'providers' => [
    // ...
    Hinet\SMS\SMSServiceProvider::class,
],

找到 aliases 并添加 Facade 到数组.

'aliases' => [
    // ...
    'SMS' => Hinet\SMS\SMSFacade::class,
],

方法

方法 MAGTI SMSOFFICE SMSCO JUHE
SMS::Send($numbers, $message, $additional_params = []) + + + +
SMS::Schedule($numbers, $message, $datetime) - - + -
SMS::Status($msg_id) + - + -
SMS::Balance() - + - -
  • $numbers - 手机号以逗号分隔, 格式: 138XXXXXXXX
  • $message - 要发送的文本信息,在聚合中是模板字符串.
  • $additional_params - 以 key => values 的数组并最终组合成Http参数.
  • $datetime - 时间,格式 Y-m-d H:i:s.
  • $msg_id - 消息ID,您将从供应商获得,检查短信的状态。

允许在消息中使用的符号:

Symbol Description
a-z Characters in the range between a and z (case sensitive)
A-Z Characters in the range between A and Z (case sensitive)
0-9 Character in the range between 0 and 9
. Point
_ Undercsore
- Dash
" Double Quotes
' Single Quote
Space

配置

使用命令来发布配置文件:

php artisan vendor:publish

将会创建一个文件 config\sms.php:

默认短信接口

您可以从下面的列表中指定任何允许的短消息服务提供程序:

允许的短消息服务: 'magti', 'smsoffice', 'smsco', 'juhe'

'default' => 'juhe',

短信提供商的凭据

在这里,您必须指定提供程序所需的凭据

此凭据将在协议中使用

'providers' => [
	'juhe' => [
		'key' => env('SMS_APP_KEY', 'SECRET_KEY'),
	],

	'smsoffice' => [
		'key' => env('SMS_PASSWORD', 'SECRET_KEY'),
		'brand' => env('SMS_USERNAME', 'BRAND_NAME'),
	],

	'smsco' => [
		'username' => env('SMS_USERNAME', 'USERNAME'),
		'password' => env('SMS_PASSWORD', 'PASSWORD'),
	],

	'magti' => [
		'username' => env('SMS_USERNAME', 'USERNAME'),
		'password' => env('SMS_PASSWORD', 'PASSWORD'),
		'client_id' => env('SMS_CLIENT_ID', 'CLIENT_ID'),
		'service_id' => env('SMS_SERVICE_ID', 'SERVICE_ID'),
	],

],

.ENV

You can configure provider credentials in your config or .env file

KEY MAGTI SMSOFFICE SMSCO
SMS_USERNAME + BRAND +
SMS_PASSWORD + KEY +
SMS_CLIENT_ID + - -
SMS_SERVICE_ID + - -

License

SMS is an open-sourced laravel package licensed under the MIT license.