GithubHelp home page GithubHelp logo

muthofun-sms-gateway's Introduction

MUTHOFUN SMS GATEWAY

muthofun-sms-gateway is a PHP client for MUTHOFUN SMS Gateway API. This package is also support Laravel and Lumen.

Installation

Go to terminal and run this command

composer require shipu/muthofun-sms-gateway

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

For Laravel

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

Shipu\MuthoFun\MuthoFunServiceProvider::class,

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

'MUTHOFUN'   =>  Shipu\MuthoFun\Facades\MuthoFun::class,

Then run this command

php artisan vendor:publish --provider="Shipu\MuthoFun\MuthoFunServiceProvider"

Configuration

This package is required two configurations.

  1. username = your username which provide by MUTHOFUN.
  2. password = your password which provide by MUTHOFUN

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

use Shipu\MuthoFun\MUTHOFUN;

$config = [
    'username' => 'Your Username',
    'password' => 'Your Password'
];

$sms = new MUTHOFUN($config);

For Laravel

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

Go to app\muthofun.php and configure it with your credentials.

return [
    'username' => 'Your Username',
    '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\MuthoFun\MuthoFun;

...

$sms = new MUTHOFUN($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\MuthoFun\Facades\MuthoFun;

...

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

// or

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

// or

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

Send same message to all users

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

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

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

Send SMS to more user

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

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

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

// or 

$sms = MUTHOFUN::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 mentions their name dynamically with message. So what can you do? Ha ha this package already handle this situations. Lets see

$users = [
    ['01670420420', ['Nahid', '1234']],
    ['01970420420', ['Rana', '3213']],
    ['01770420420', ['Shipu', '5000']],
    ['01570420420', ['Kaiser', '3214']],
    ['01870420420', ['Eather', '7642']]
]
$sms = new \Shipu\MuthoFun\MUTHOFUN(config('muthofun'));
$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\MuthoFun\MUTHOFUN(config('muthofun'));
$msg = $sms->message("Hello %s , Your promo code is: %s", $users)->send();

Here this messege will sent as every users with his 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 = MUTHOFUN::numberPrefix('91')->message('your text here !!!', '01606022000')->send();

Default number prefix is 88;

Debugging

$sms = MUTHOFUN::debug(true)->message('your text here !!!', '01606022000')->send();

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

Response Data auto parse

$sms = MUTHOFUN::autoParse(true)->message('your text here !!!', '01606022000')->send();

Default value is false.

Disable Template

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

Default value is true.

Response Data

$sms->autoParse();

Response :

SimpleXMLElement {#212 ▼
    +"sms": SimpleXMLElement {#216 ▼
        +"smsclientid": "713231739"
        +"messageid": "500930552"
        +"mobile-no": "+8801616022669"
}

Highly inspired by Apiz Package and Sslwireless SMS Gateway

Special Thanks to Salahuddin Rana

Support on Beerpay

Hey dude! Help me out for a couple of 🍻!

Beerpay Beerpay

muthofun-sms-gateway's People

Contributors

mobarokhossain avatar shipu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

muthofun-sms-gateway's Issues

Newline in SMS Text

What should I use for 'new line' character in my SMS body?
I used '\n' and it didn't work.

Issue with Laravel Queue

Okay, here I found a issue while using with Laravel queue.
Queue:work only can send first sms, and then for every sms it hrows this:

[] operator not supported for strings {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): [] operator not supported for strings at /home/farhad/html/sust_admission/vendor/shipu/muthofun-sms-gateway/src/MUTHOFUN.php:56)

And this is Job Class

`<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use \Shipu\MuthoFun\Facades\MuthoFun;

class SMS_SendExactMessage implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

/**
 * The number of times the job may be attempted.
 *
 * @var int
 */
public $tries = 100;


public $message, $number;
/**
 * Create a new job instance.
 *
 * @return void
 */
public function __construct($message, $number)
{
    $this->message = $message;
    $this->number = $number;
}

/**
 * Execute the job.
 *
 * @return void
 */
public function handle()
{
    $sms = MUTHOFUN::message($this->message, $this->number)->send();
}

}
`

I found a workaround.

But I thought it would be helpful to notify you.
Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.