sarahman/sms-service-with-bd-providers

PHP 短信网关服务库。一个库中包含孟加拉国的多个服务提供商

1.0.5 2024-03-29 17:58 UTC

This package is auto-updated.

Last update: 2024-08-29 18:49:51 UTC


README

Latest Version on Packagist Build Status Quality Score StyleCI Total Downloads License PHP Version Require

一个简单的 PHP 库,用于与各种短信网关交互,向孟加拉国移动用户发送短信,并存储短信请求日志。

安装

请使用 composer 安装此库。运行以下 composer 命令以添加此库。

composer require sarahman/sms-service-with-bd-providers

接下来,您需要安装服务提供者

// app/config/app.php
    .....
    .....
    'providers' => [
        ...
        Sarahman\SmsService\SmsGatewayServiceProvider::class,
    ],
    .....
    .....

您可以使用以下命令发布配置文件

对于 Laravel 版本 4.*

php artisan config:publish sarahman/sms-service-with-bd-providers

对于 Laravel 版本大于 4

php artisan vendor:publish --provider="Sarahman\SmsService\ServiceProviderForLaravelRecent"

这是发布配置文件的内容

<?php

use Sarahman\SmsService\Client;

return [
    'default' => [
        'provider' => Client::PROVIDER_SSL,
    ],

    'providers' => [
        Client::PROVIDER_BANGLALINK => [
            'url' => 'https://vas.banglalinkgsm.com/sendSMS/sendSMS',
            'userID' => '',
            'passwd' => '',
            'sender' => '',
        ],
        Client::PROVIDER_BD_WEB_HOST_24 => [
            'url' => 'http://sms.bdwebhost24.com/smsapi',
            'senderid' => '',
            'api_key' => '',
            'type' => 'text',
        ],
        Client::PROVIDER_BOOM_CAST => [
            'url' => 'http://api.boom-cast.com/boomcast/WebFramework/boomCastWebService/externalApiSendTextMessage.php',
            'userName' => '',
            'password' => '',
            'MsgType' => 'TEXT',
            'masking' => 'S.H.P.L',
        ],
        Client::PROVIDER_BULK_SMS_BD => [
            'url'      => 'http://bulksmsbd.net/api/smsapi',
            'api_key'  => '',
            'senderid' => '',
            'type'     => 'text',
        ],
        Client::PROVIDER_ELITBUZZ => [
            'url' => 'https://msg.elitbuzz-bd.com/smsapi',
            'api_key' => '',
            'senderid' => '',
            'type' => 'text',
        ],
        Client::PROVIDER_GRAMEENPHONE => [
            'url' => 'https://cmp.grameenphone.com/gpcmpapi/messageplatform/controller.home',
            'username' => '',
            'password' => '',
            'countrycode' => '880',
            'cli' => '',
            'apicode' => 1,
            'messagetype' => 1, // 1: Text; 2: Flash; 3: Unicode (Bangla)
            'messageid' => 0,
        ],
        Client::PROVIDER_NOVOCOM => [
            'url' => 'https://sms.novocom-bd.com/api/v2/SendSMS',
            'ApiKey' => '',
            'ClientId' => '',
            'SenderId' => '',
        ],
        Client::PROVIDER_PAYSTATION => [
            'url' => 'https://sms.shl.com.bd/sendsms',
            'user_id' => '',
            'password' => '',
            'type' => 'text',
        ],
        Client::PROVIDER_ROBI => [
            'url' => 'https://bmpws.robi.com.bd/ApacheGearWS/SendTextMessage',
            'Username' => '',
            'Password' => '',
            'From' => '',
        ],
        Client::PROVIDER_SSL => [
            'url' => 'http://sms.sslwireless.com/pushapi',
            'user' => '',
            'pass' => '',
            'sid' => '',
        ],
        Client::PROVIDER_VALUE_FIRST => [
            'url' => 'http://www.myvaluefirst.com/smpp/sendsms',
            'username' => '',
            'password' => '',
            'from' => '',
            'coding' => 3, // Unicode allows or not
        ],
    ],
    'enable_api_call_logging' => false,
];

现在,您需要设置所需使用的各种短信提供商的默认凭据。

注意:此库直接依赖于包:sarahman/laravel-http-request-api-log。请参阅 此链接 了解该包的使用方法。

用法

<?php

use Sarahman\SmsService\Client;

require "vendor/autoload.php";

// Instantiate with default config
$smsSender = new Client(Client::getProvider(Client::PROVIDER_SSL));

// Or instantiate with custom config
$smsSender = new Client(Client::getProvider(Client::PROVIDER_SSL, [
    'user' => 'SSL_WIRELESS_USERNAME',
    'pass' => 'SSL_WIRELESS_PASSWORD',
    'sid' => 'SSL_WIRELESS_SID',
], 'SSL_WIRELESS_URL'));

try {
    $response = $smsSender->send($mobile, $message);

    if ($response['summary']['sent'] == $response['summary']['total']) {
        // Do for the successful response.
    } else {
        // Do for the failed response.
    }
} catch (Exception $e) {
    echo $e->getMessage();
}

支持的提供商

对于其他网关提供商

如果您有自己的短信网关并提供 API,请构建自己的提供者并向我们发送拉取请求。我们也会在这里添加这些。

要构建自己的提供者,请参考 src/Interfaces/ProviderInterface.php

如果您有任何问题,请随时创建一个 issue 或给我们发送邮件至 aabid048@gmail.com

贡献

请随意为此库做出贡献。添加您自己的提供者并向我们发送 pull requests

安全问题

如果您发现任何与安全相关的问题,请随时在 issue 跟踪器 中创建 issue 或给我们发送邮件至 aabid048@gmail.com

许可

MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件