developifynet/sms4connect-php

PHP的SMS 4 Connect SMS API包装器

v1.0.1 2020-04-21 17:12 UTC

This package is auto-updated.

Last update: 2024-09-22 03:29:42 UTC


README

Build Status Total Downloads Latest Stable Version License

此composer包为您提供了为PHP或Laravel应用程序快速设置短信的功能。

安装

首先通过Composer引入该包。

composer require developifynet/sms4connect-php

Laravel框架使用

在您的控制器中,您可以调用Sms4Connect外观并快速发送短信。

发送短信

发送单个号码的短信
use Developifynet\Sms4Connect\Sms4Connect;
public function index()
{
    $SMSObj = array(
        'id' => '<PUT_YOUR_ACCOUNT_ID_HERE>',               // Use your account id here
        'password' => '<PUT_YOUR_ACCOUNT_PASSWORD_HERE>',   // Use your account password here
        'to' => '923XXXXXXXXX',                             // You can provide single number as string or an array of numbers
        'msg' => '<PUT_YOUR_MESSAGE_HERE>',                 // Message string you want to send to provided number(s)
        'mask' => '<PUT_YOUR_MASK_HERE>',                   // Use a registered mask with SMS 4 Connect
        'test_mode' => '0',                                 // 0 for Production, 1 for Mocking as Test
     );
    
    $response = Sms4Connect::SendSMS($SMSObj);
}
发送多个号码的短信
use Developifynet\Sms4Connect\Sms4Connect;
public function index()
{
    $SMSObj = array(
        'id' => '<PUT_YOUR_ACCOUNT_ID_HERE>',               // Use your account id here
        'password' => '<PUT_YOUR_ACCOUNT_PASSWORD_HERE>',   // Use your account password here
        'to' => ['923XXXXXXXXX', '923XXXXXXXXX'],,          // You can provide single number as string or an array of numbers
        'msg' => '<PUT_YOUR_MESSAGE_HERE>',                 // Message string you want to send to provided number(s)
        'mask' => '<PUT_YOUR_MASK_HERE>',                   // Use a registered mask with SMS 4 Connect
        'test_mode' => '0',                                 // 0 for Production, 1 for Mocking as Test
     );
    
    $response = Sms4Connect::SendSMS($SMSObj);
}

检查投递状态

检查单个交易的投递状态
use Developifynet\Sms4Connect\Sms4Connect;
public function index()
{
    $SMSObj = array(
        'id' => '<PUT_YOUR_ACCOUNT_ID_HERE>',               // Use your account id here
        'password' => '<PUT_YOUR_ACCOUNT_PASSWORD_HERE>',   // Use your account password here
        'transaction' => 'XXXXXXXXX',                       // You can provide single sms transaction id as string or an array of numbers
        'test_mode' => '0',                                 // 0 for Production, 1 for Mocking as Test
    );
    
    $sms4connect = new Sms4ConnectSMS::checkDeliveryStatus($SMSObj);
}
检查多个交易的投递状态
use Developifynet\Sms4Connect\Sms4Connect;
public function index()
{
    $SMSObj = array(
        'id' => '<PUT_YOUR_ACCOUNT_ID_HERE>',               // Use your account id here
        'password' => '<PUT_YOUR_ACCOUNT_PASSWORD_HERE>',   // Use your account password here
        'transaction' => ['XXXXXXXXX', 'XXXXXXXXX'],        // You can provide single sms transaction id as string or an array of numbers
        'test_mode' => '0',                                 // 0 for Production, 1 for Mocking as Test
    );
    
    $sms4connect = new Sms4ConnectSMS::checkDeliveryStatus($SMSObj);
}

检查账户余额

use Developifynet\Sms4Connect\Sms4Connect;
public function index()
{
    $SMSObj = array(
        'id' => '<PUT_YOUR_ACCOUNT_ID_HERE>',               // Use your account id here
        'password' => '<PUT_YOUR_ACCOUNT_PASSWORD_HERE>',   // Use your account password here
        'test_mode' => '0',                                 // 0 for Production, 1 for Mocking as Test
    );
    
    $sms4connect = new Sms4ConnectSMS::checkBalance($SMSObj);
}

其他使用

在您的控制器中,您可以调用Sms4ConnectSMS对象并发送快速短信。

发送短信

发送单个号码的短信
use \Developifynet\Sms4Connect\Sms4ConnectSMS;
public function index()
{
    $SMSObj = array(
        'id' => '<PUT_YOUR_ACCOUNT_ID_HERE>',               // Use your account id here
        'password' => '<PUT_YOUR_ACCOUNT_PASSWORD_HERE>',   // Use your account password here
        'to' => '923XXXXXXXXX',                             // You can provide single number as string or an array of numbers
        'msg' => '<PUT_YOUR_MESSAGE_HERE>',                 // Message string you want to send to provided number(s)
        'mask' => '<PUT_YOUR_MASK_HERE>',                   // Use a registered mask with SMS 4 Connect
        'test_mode' => '0',                                 // 0 for Production, 1 for Mocking as Test
    );
    
    $sms4connect = new Sms4ConnectSMS();
    $response = $sms4connect->SendSMS($SMSObj);
}
发送多个号码的短信
use \Developifynet\Sms4Connect\Sms4ConnectSMS;
public function index()
{
    $SMSObj = array(
        'id' => '<PUT_YOUR_ACCOUNT_ID_HERE>',               // Use your account id here
        'password' => '<PUT_YOUR_ACCOUNT_PASSWORD_HERE>',   // Use your account password here
        'to' => ['923XXXXXXXXX', '923XXXXXXXXX'],,          // You can provide single number as string or an array of numbers
        'msg' => '<PUT_YOUR_MESSAGE_HERE>',                 // Message string you want to send to provided number(s)
        'mask' => '<PUT_YOUR_MASK_HERE>',                   // Use a registered mask with SMS 4 Connect
        'test_mode' => '0',                                 // 0 for Production, 1 for Mocking as Test
     );
    
    $sms4connect = new Sms4ConnectSMS();
    $response = $sms4connect->SendSMS($SMSObj);
}

检查投递状态

检查单个交易的投递状态
use \Developifynet\Sms4Connect\Sms4ConnectSMS;
public function index()
{
    $SMSObj = array(
        'id' => '<PUT_YOUR_ACCOUNT_ID_HERE>',               // Use your account id here
        'password' => '<PUT_YOUR_ACCOUNT_PASSWORD_HERE>',   // Use your account password here
        'transaction' => 'XXXXXXXXX',                       // You can provide single sms transaction id as string or an array of numbers
        'test_mode' => '0',                                 // 0 for Production, 1 for Mocking as Test
    );
    
    $sms4connect = new Sms4ConnectSMS();
    $response = $sms4connect->checkDeliveryStatus($SMSObj);
}
检查多个交易的投递状态
use \Developifynet\Sms4Connect\Sms4ConnectSMS;
public function index()
{
    $SMSObj = array(
        'id' => '<PUT_YOUR_ACCOUNT_ID_HERE>',               // Use your account id here
        'password' => '<PUT_YOUR_ACCOUNT_PASSWORD_HERE>',   // Use your account password here
        'transaction' => ['XXXXXXXXX', 'XXXXXXXXX'],        // You can provide single sms transaction id as string or an array of numbers
        'test_mode' => '0',                                 // 0 for Production, 1 for Mocking as Test
    );
    
    $sms4connect = new Sms4ConnectSMS();
    $response = $sms4connect->checkDeliveryStatus($SMSObj);
}

检查账户余额

use \Developifynet\Sms4Connect\Sms4ConnectSMS;
public function index()
{
    $SMSObj = array(
        'id' => '<PUT_YOUR_ACCOUNT_ID_HERE>',               // Use your account id here
        'password' => '<PUT_YOUR_ACCOUNT_PASSWORD_HERE>',   // Use your account password here
        'test_mode' => '0',                                 // 0 for Production, 1 for Mocking as Test
    );
    
    $sms4connect = new Sms4ConnectSMS();
    $response = $sms4connect->checkBalance($SMSObj);
}

注意

提供的号码应以国家代码开头。例如,巴基斯坦的号码应写作923XXXXXXXXX。