fastsms/sdk
Composer 安装命令:
composer require fastsms/sdk
包简介
SDK for FastSMS api.
关键字:
README 文档
README
PHP library to access FastSMS api.
Thank you for choosing FastSMS
DIRECTORY STRUCTURE
src/ core wrapper code
tests/ tests of the core wrapper code
REQUIREMENTS
The minimum requirement by FastSMS wrapper is that your Web server supports PHP 5.4.
DOCUMENTATION
FastSMS has a Knowledge Base and a Developer Zone which cover every detail of FastSMS API.
INSTALLATION
Add to composer
"require": { ... "fastsms/sdk": "*", ... }
USAGE
Init SDK
Your token (found in your settings within NetMessenger)
$FastSMS = new FastSMS\Client('your token');
or
use FastSMS\Client;
...
$FastSMS = new Client('your token');
...
Wrap errors
List all API codes found in docs
use FastSMS\Client;
use FastSMS\Exception\ApiException;
...
$client = new Client('your token');
try {
$credits = $client->credits->getBalance();
} catch (ApiException $aex) {
echo 'API error #' . $aex->getCode() . ': ' . $aex->getMessage();
} catch (Exception $ex) {
echo $ex->getMessage();
}
Actions
Credits
Checks your current credit balance.
$credits = $client->credits->balance; //return float val
echo number_format($credits, 2); //example show 1,000.00
Send
Sends a message. More information read this
...
use FastSMS\Model\Message;
...
// Init Message data
$data = [
//set
'destinationAddress' => 'Phone number or multiple numbers in array',
//or
'list' => 'Your contacts list',
//or
'group' => 'Your contacts group'
'sourceAddress' => 'Your Source Address',
'body' => 'Message Body', //Note: max 459 characters
//optionals
'scheduleDate' => time() + 7200, //now + 2h
'validityPeriod' => 3600 * 6, //maximum 86400 = 24 hours
'sourceTON' => 1, //The Type Of Number for the source address (1 for international, 5 for alphanumeric)
];
$result = $client->message->send($data);
Check message status
Check send message status. More information read this
$result = $client->message->status($messageId);// Message Id must be integer
Create User
Create new child user. Only possible if you are an admin user. More information read this
...
use FastSMS\Model\User;
// Init user data
$data = [
'childUsername' => 'Username',
'childPassword' => 'Password',
'accessLevel' => 'Normal', //or 'Admin'
'firstName' => 'John',
'lastName' => 'Doe',
'email' => 'user@example.com',
'credits' => 100,
//optionals
'telephone' => 15417543010, // integer
'creditReminder' => 10,
'alert' => 5, //5 days
];
$result = $client->user->create($data);
Update Credits
Transfer credits to/from a child user. Only possible if you are an admin user. More information read this
...
use FastSMS\Model\User;
// Init update user data
$data = [
'childUsername' => 'Exist Username',
'quantity' => -5, //The amount of credits to transfer.
];
$user = new User($data);
$result = $client->user->update($user);
Reports
Retrieve the data from a report. More information read this Aviable types:
- ArchivedMessages
- ArchivedMessagesWithBodies
- ArchivedMessagingSummary
- BackgroundSends
- InboundMessages
- KeywordMessageList
- Messages
- MessagesWithBodies
- SendsByDistributionList
- Usage
...
use FastSMS\Model\Report;
...
// Init Report params
$data = [
'reportType' => 'Messages',
'from' => time() - 3600 * 24 * 30,
'to' => time()
];
// Get report
$result = $client->report->get($data);
Add contact(s)
Create contact(s). More information read this
...
use FastSMS\Model\Contact;
...
// Init Contacts data
$data = [
'contacts' => [
['name' => 'John Doe 1', 'number' => 15417543011, 'email' => 'john.doe.1@example.com'],
['name' => 'John Doe 2', 'number' => 15417543012, 'email' => 'john.doe.2@example.com'],
['name' => 'John Doe 3', 'number' => 15417543013, 'email' => 'john.doe.3@example.com'],
],
'ignoreDupes' => false,
'overwriteDupes' => true
];
// Get report
$result = $client->contact->create($data);
Delete All Contacts
More information read this
...
use FastSMS\Model\Contact;
...
// Get report
$result = $client->contact->deleteAll();
Delete All Groups
More information read this
...
use FastSMS\Model\Contact;
...
// Get report
$result = $client->group->deleteAll();
Empty Group
Remove all contacts from the specified group. More information read this
...
use FastSMS\Model\Contact;
...
// Get report
$result = $client->group->empty('Group Name');
Delete Group
Delete the specified group. More information read this
...
use FastSMS\Model\Contact;
...
// Get report
$result = $client->group->delete('Group Name');
fastsms/sdk 适用场景与选型建议
fastsms/sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 42.83k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2015 年 06 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「newsletter」 「sms」 「sdk」 「fastsms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fastsms/sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fastsms/sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fastsms/sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Manage newsletters in Laravel
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
Extensible library for building notifications and sending them via different delivery channels.
Sendrill DB
The Newsletter Module provides the newsletter features to manage newsletters and mailing lists.
统计信息
- 总下载量: 42.83k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2015-06-12