grambas/sms-gateway

Laravel 5.2 的 API 容器

v1.0 2016-08-29 09:33 UTC

This package is auto-updated.

Last update: 2024-09-13 05:29:46 UTC


README

基本 https://gatewayapi.com/ API 容器,适用于 Laravel 5.*

需求

  • "guzzlehttp/guzzle": "~6.0"

安装

通过 Composer

$ composer require grambas/SmsGateway dev-master

用法

发送短信的简单示例

$client = new SmsGateway( 'API KEY','SECRET KEY'); // init client with api key and secret
$response = $client->send('SENDER NAME', '048139381038', 'Message content'); //send sms with paramters: sender name, phone nunbmer and message

if (  isset($response['ids']) ) { // if message is sent, then the system generates id. So if id exist, then the message is successfuly snent
    return "Message successfuly sent!  Cost: " . $response['usage']['total_cost'] . ' ' . $response['usage']['currency'];
}else{
    return 'Error acquired during sending message';
}

检查余额

$client = new SmsGateway( 'API KEY','SECRET KEY');
$check = $client->me();
return 'New balance: ' . $check['credit']  . ' ' . $check['currency'];


许可协议

MIT 许可协议 (MIT)。请参阅许可文件以获取更多信息。