shipu/banglalink-sms-gateway 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

shipu/banglalink-sms-gateway

Composer 安装命令:

composer require shipu/banglalink-sms-gateway

包简介

Banglalink sms gateway

README 文档

README

A PHP client for Banglalink SMS Gateway API. This package is also support Laravel and Lumen.

Installation

Go to terminal and run this command

composer require shipu/banglalink-sms-gateway

Wait for few minutes. Composer will automatically install the package for your project.

For Laravel

Below Laravel 5.5 open config/app and add this line in providers section

Shipu\BanglalinkSmsGateway\Providers\BanglalinkSmsGatewayServiceProvider::class,

For Facade support you have to add this line in the aliases section.

'Banglalink'   =>  Shipu\BanglalinkSmsGateway\Facades\Banglalink::class,

Then run this command

php artisan vendor:publish --provider="Shipu\BanglalinkSmsGateway\Providers\BanglalinkSmsGatewayServiceProvider"

For PHP Configuration

This package is required two configurations.

  1. user_id = your user_id which is provided by Banglalink.
  2. password = your password which is also provided by Banglalink.

banglalink-sms-gateway is take an array as config file. Lets services

use Shipu\BanglalinkSmsGateway\Banglalink;

$config = [
    'user_id' => 'Your User Id',
    'password' => 'Your Password'
];

$sms = new Banglalink($config);

For Laravel Configuration

This package is also support Laravel. For laravel you have to configure it as laravel style.

Go to config/banglalink-sms-gateway.php and configure it with your credentials.

return [
    'user_id' => 'Your User id',
    'password' => 'Your Password'
];

Usages

Its very easy to use. This packages has a lot of functionalities and features.

Send SMS to a single user

In PHP:

use \Shipu\BanglalinkSmsGateway\Services\Banglalink;

...

$sms = new Banglalink($config);
$response = $sms->message('your text here !!!', '01606022000')->send(); // Guzzle Response with request data

// For another example please see below laravel section. 
 
return $response->autoParse(); // Getting only response contents.

In Laravel:

use \Shipu\BanglalinkSmsGateway\Facades\Banglalink;

...

$sms = Banglalink::message('your text here !!!', '01606022000')->send(); // Guzzle Response with request data

// or

$sms = Banglalink::message('your text here !!!')->to('01606022000')->send();

// or

$sms = Banglalink::send(
    [
        'message' => "your text here",
        'to' => '01616022000'
    ]
);
return $sms->autoParse(); // Getting only response contents.

Send same message to all users

$sms = Banglalink::message('your text here !!!')
            ->to('01616022669')
            ->to('01845736124')
            ->to('01745987364')
            ->send();
            
// or you can try below statements also

$sms = Banglalink::message('your text here !!!', '01616022669')
            ->to('01845736124')
            ->to('01745987364')
            ->send();
            
// or           

$users = [
    '01616022669',
    '01845736124',
    '01745987364'
];        
$sms = Banglalink::message('your text here !!!',$users)->send(); 

Send SMS to more user

$sms = Banglalink::message('your text here one !!!')->to('01616022669')
            ->message('your text here two !!!')->to('01845736124')
            ->message('your text here three !!!')->to('01745987364')
            ->send();
// or

$sms = Banglalink::message('your text here one !!!', '01616022669')
            ->message('your text here two !!!', '01845736124')
            ->message('your text here three !!!', '01745987364')
            ->send();
            
// or 

$sms = Banglalink::send([
    [
        'message' => "your text here one !!!",
        'to' => '01616022669'
    ],
    [
        'message' => "your text here two !!!",
        'to' => '01707722669'
    ],
    [
        'message' => "your text here three !!!",
        'to' => '01745987364'
    ]
]);

// or 

$sms = Banglalink::message('your text here one !!!', '01616022669')->send([
    [
        'message' => "your text here two !!!",
        'to' => '01707722669'
    ],
    [
        'message' => "your text here three !!!",
        'to' => '01745987364'
    ]
]);         

Send SMS with SMS template

Suppose you have to send SMS to multiple users but you want to mention their name dynamically with message. So what can you do? Ha ha this package has already handled this situation. Lets see

$users = [
    ['01670420420', ['Nahid', '1234']],
    ['01970420420', ['Rana', '3213']],
    ['01770420420', ['Shipu', '5000']],
    ['01570420420', ['Kaiser', '3214']],
    ['01870420420', ['Eather', '7642']]
]
$sms = new \Shipu\BanglalinkSmsGateway\Services\Banglalink(config('banglalink-sms-gateway'));
$msg = $sms->message("Hello %s , Your promo code is: %s", $users)->send();

// or 

$users = [
    '01670420420' => ['Nahid', '1234'],
    '01970420420' => ['Rana', '3213'],
    '01770420420' => ['Shipu', '5000'],
    '01570420420' => ['Kaiser', '3214'],
    '01870420420' => ['Eather', '7642']
]
$sms = new \Shipu\BanglalinkSmsGateway\Services\Banglalink(config('banglalink-sms-gateway'));
$msg = $sms->message("Hello %s , Your promo code is: %s", $users)->send();

Here this message will be sent to every users with his/her name and promo code like:

  • 8801670420420 - Hello Nahid , Your promo code is: 1234
  • 8801970420420 - Hello Rana , Your promo code is: 3213
  • 8801770420420 - Hello Shipu , Your promo code is: 5000
  • 8801570420420 - Hello Kaiser , Your promo code is: 1234
  • 8801870420420 - Hello Eather , Your promo code is: 7642

Change Number Prefix

$sms = Banglalink::numberPrefix('91')->message('your text here !!!', '01606022000')->send();

Default number prefix is 88;

Send sms with sender name

$sms = Banglalink::sender('XYZ Company')->message('your text here !!!', '01606022000')->send();

Default sender name is null. for details please contact to banglalink customer support;

Debugging

$sms = Banglalink::debug(true)->message('your text here !!!', '01606022000')->send(); // // debug true or blank.

Default value is false. When debug true it's stop sending SMS and return sending query strings.

Response Data auto parse

$sms = Banglalink::autoParse(true)->message('your text here !!!', '01606022000')->send(); // autoParse true or blank.

Default value is false.

Disable Template

$sms = Banglalink::template(false)->message('your text here !!!', '01606022000')->send();

Default value is true.

Response Data

dd($sms);

Response :

Response {#463 ▼
  #response: Response {#446 ▶}
  #request: Request {#428 ▼
    -method: "GET"
    -requestTarget: null
    -uri: Uri {#429 ▶}
    -headers: []
    -headerNames: []
    -protocol: "1.1"
    -stream: null
    +"details": array:3 [▼
      "url" => "https://vas.banglalinkgsm.com/sendSMS/sendSMS"
      "method" => "GET"
      "parameters" => array:1 [▼
        "query" => array:5 [▶]
      ]
    ]
  }
  #contents: "Success Count : 2 and Fail Count : 0"
}

Response auto parse:

dd($sms->autoParse());

Response

"Success Count : 2 and Fail Count : 0"

Response Details

$sms = Banglalink::details()->message('your text here !!!', '01606022000')->send();

Response:

[
    'success' => 1,
    'failed' => 0
]

统计信息

  • 总下载量: 1.14k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 32
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 32
  • Watchers: 1
  • Forks: 20
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-07-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固