saishirwadinformatia / sendsms
使用Sai Ashirwad批量短信服务发送短信
2.5
2021-05-29 08:47 UTC
Requires
- php: ^7.2.5
- guzzlehttp/guzzle: ^7.2
- phpunit/phpunit: ^9.1
- vlucas/phpdotenv: ^5.3
Requires (Dev)
- pestphp/pest: ^1.2
- symfony/var-dumper: ^5.0
README
通过在https://saiashirwad.in注册,轻松在全球任何地方发送短信。
包功能
- 国家代码验证
- 通过国家代码和已知手机前缀验证手机号码
- 通过国家代码验证手机号码长度
- 发送交易短信
- 发送促销短信
- 通过短信发送OTP [开发中]
- 轻松检查余额
验证功能建立在可验证源Wikipedia之上
好处
- 在触发短信或想要注册号码之前,库提供了识别未知号码的方法
- 节省发送到错误号码的信用额度,只与真实号码明智地使用
- 轻松集成到任何PHP应用程序中,无论使用的框架是什么。
安装
composer require saiashirwadinformatia/sendsms
- 注册 - https://saiashirwad.in
- 检索API密钥 - https://saiashirwad.in/user/#api
用法
出于凭据和身份的安全性,Send SMS包读取.env或环境变量,因此配置将在git提交之外保持安全。
发送短信
use SaiAshirwadInformatia\SendSMS;
/**
* Retrieve your key from https://saiashirwad.in/user/#api
*
* Connect on support@saiashirwad.com for queries
*/
$apiKey = 'API_KEY';
// If API Key is given null, it will attempt to read from env as `SMS_SEND_KEY`
/**
* Default is "91"
*/
$countryCode = '91';
/**
* Seen on receivers phone a 6 characters Sender Id
*
* Default is "SAIMSG"
*
* Exact length required "6"
*/
$senderId = 'ABCDEF';
/**
* Please note, this cannot be less than or greater than 6, should be exact 6 characters
* Available Routes
* SendSMS::TRANSACTION_ROUTE => transaction (Received by DND)
* SendSMS::PROMOTIONAL_ROUTE => promotional (Ignored by DND)
*
* Please note, transaction require's explicit opt-in in your application
* We may ask you this data, if any complains/reports received
*/
$route = SendSMS::TRANSACTION_ROUTE;
$smsClient = new SendSMS([
'authkey' => $apiKey,
'countryCode' => $countryCode,
'senderId' => $senderId,
'route' => $route
]);
/**
* Mobile number
*
* This can also be comma separate string for multiple phone numbers
*/
$mobile = '8888888888';
/**
* Message upto 160 characters is considered as "1" credit
* If it goes beyond the desired limit's credit's are charged accordingly
*/
$message = 'Hello, this is your message!';
$countryCode = '91'; // dynamically change country code during each call
$senderId = 'TESTMM'; // dynamically set sender id for each SMS
$dltTemplateId = ''; // This is now mandatory to send SMS in authentic way
$success = $smsClient->send($dltTemplateId, $mobile, $message, $countryCode,
// returns SMS Message Id for tracking
echo $success->getMessage();
检查余额
use SaiAshirwadInformatia\SendSMS;
/**
* Retrieve your key from https://saiashirwad.in/user/#api
*
* Connect on support@saiashirwad.com for queries
*/
$apiKey = 'API_KEY';
// Default is Transaction route, alternate is SendSMS::PROMOTIONAL_ROUTE
$route = SendSMS::TRANSACTION_ROUTE;
$smsClient = new SendSMS();
// Alternate way
$smsClient->setAuthKey($apiKey);
// Fetch balance for selected route either transaction or promotion
$balance = $smsClient->checkBalance($route);
echo $balance->getCount(); // returns integer of available SMS credits count
对于学生/试用账户
将为来自印度的大学项目学生提供免费短信信用额度(有限),请联系support@saiashirwad.com
许可证
MIT许可证
版权
Sai Ashirwad Informatia,2020