smsgateway24 / smsgateway24-php-sdk
php sdk for smsgateway24.com
v2.0.0
2021-07-27 14:15 UTC
Requires
- php: >=7.1
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpunit/phpunit: ^9.5
- roave/backward-compatibility-check: ^5.0
- symfony/test-pack: ^1.0
This package is not auto-updated.
Last update: 2024-09-18 05:43:43 UTC
README
SmsGateWay24 是一项服务,可以将您的安卓手机变成网关,并通过它发送短信。
PHP SDK
用于与 SmsGateWay24 API 交互的 PHP 库。
需求
- PHP 7.1+
以下是如何使用它的示例
use \SmsGateway24\SmsGateway24; $gateway = new SmsGateway24('your-api-token-here'); // get it in your profile $to = "+4915752982212"; //required. Target Phone number $message = "Hello, how are you?"; // required. Body Message. $deviceId = 10403; //required. get it in your profile after app installation on your android $sim=0; // Optional. 0 or 1. For Dual SIM devices. (if you skip it -> default sim is 0) $timeToSend = "2022-01-12 00:00:00"; // Optional. time when you want to send SMS $customerid = 12; // Optional. your internal customer ID. $urgent = 1; // Optional. 1 or 0 to make sms Urgent. $smsId = $gateway->addSms($to, $message, $deviceId, $timeToSend, $sim, $customerid, $urgent);
之后,安装了 Smsgateway24 应用的手机会调用服务器,并从您的SIM卡发送短信。
入门指南
访问我们的 网站,注册并安装手机应用。获取您的API令牌和设备ID。
通过 composer 安装包
composer require smsgateway24/smsgateway24-php-sdk
API 方法
将短信添加到队列
在服务器上创建要发送的短信。
use \SmsGateway24\SmsGateway24; $gateway = new SmsGateway24('your-api-token-here'); // get it in your profile $to = "+4915752982212"; //required. Target Phone number $message = "Hello, how are you?"; // required. Body Message. $deviceId = 10403; //required. get it in your profile after app installation on your android $sim=0; // Optional. 0 or 1. For Dual SIM devices. (if you skip it -> default sim is 0) $timeToSend = "2022-01-12 00:00:00"; // Optional. time when you want to send SMS $customerid = 12; // Optional. your internal customer ID. $urgent = 1; // Optional. 1 or 0 to make sms Urgent. $smsId = $gateway->addSms($to, $message, $deviceId, $timeToSend, $sim, $customerid, $urgent); echo $smsId;
获取短信状态
您可以使用此方法查询每条短信的状态
use \SmsGateway24\SmsGateway24; $gateway = new SmsGateway24('your-api-token-here'); // get it in your profile $smsId = 12345; $statusResult = $gateway->getSmsStatus($smsId); print_r($statusResult); /* Statuses values: 1 - New (just created) 2 - Taken from Server. The phone picked up the SMS from the server, but there is no information about the delivery yet. 5 - Income. 6 - Sent by Phone. Good status. The phone sent a text message. But there is no information about the delivery yet. 7 - Delivered. Good status. The phone texted and it was 100% delivered by the operator. The delivery status was sent to the server. (You need a webhook to your server - we have one! Write your server in the device settings on the website) 8 - Sms Not Delivered. The text message was not delivered. This usually means that the SIM card is blocked or the balance is negative 9 - Not SENT - Generic failure. The text message was not delivered. This usually means that the SIM card is blocked or the balance is negative 10 - Not sent - No service. 11 - Not Sent - Null PD. 12 - Not Sent - Radio off. 100 - not sent - NOT ALLOWED. Click the permission button in the app 101 - not sent - Not Allowed At all. Click the permission button in the app */
获取设备状态
use \SmsGateway24\SmsGateway24; $gateway = new SmsGateway24('your-api-token-here'); // get it in your profile $deviceId = 12345; // get it in your profile $statusResult = $gateway->getDeviceStatus($deviceId); print_r($statusResult);
添加标签
为任何标签添加联系人。例如,对于标签 * 员工 *,您的同事将非常合适。
use \SmsGateway24\SmsGateway24; $gateway = new SmsGateway24('your-api-token-here'); // get it in your profile $tagId = $gateway->saveTag("Rich customers"); echo $tagId;
保存联系人
为任何标签添加联系人。例如,对于标签 * 员工 *,您的同事将非常合适。
use \SmsGateway24\SmsGateway24; $gateway = new SmsGateway24('your-api-token-here'); // get it in your profile $contactName = 'Support SmsGateWay24'; $phoneNum = '+4915752982212'; $tagId = 2456; $contactId = $gateway->saveContact($contactName, $phoneNum, $tagId); echo $contactId;
创建通讯录
创建标签后,您可以在标签手机上进行群发。
use \SmsGateway24\SmsGateway24; $gateway = new SmsGateway24('your-api-token-here'); // get it in your profile $paketTitle = 'some title'; $deviceId = 1234; // get it in your profile $body = 'body text'; $tags = [12, 13, 14]; // ids $paketId = $gateway->savePaket($paketTitle, $deviceId, $body, $tags); echo $paketId;
贡献
欢迎贡献!