Skip to content

Commit

Permalink
Option to customize the base_uri - #12
Browse files Browse the repository at this point in the history
  • Loading branch information
robincsamuel committed Mar 17, 2020
1 parent 1d961a5 commit 81dcfa4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
44 changes: 25 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Add `robincsamuel/laravel-msg91` to your composer requirements:

Now run `composer update`

Once the package is installed, open your `app/config/app.php` configuration file and locate the `providers` key. Add the following line to the end:
Once the package is installed, open your `app/config/app.php` configuration file and locate the `providers` key. Add the following line to the end:

```php
RobinCSamuel\LaravelMsg91\LaravelMsg91ServiceProvider::class
Expand All @@ -37,7 +37,12 @@ Next, locate the `aliases` key and add the following line:
```php
'LaravelMsg91' => RobinCSamuel\LaravelMsg91\Facades\LaravelMsg91::class,
```
Put the credentials & preferences in ENV with the keys `MSG91_KEY`, `MSG91_SENDER_ID`, `MSG91_ROUTE`, `MSG91_COUNTRY`. If you wan't to customize this, publish the default configuration which will create a config file `config/msg91.php`.

Put the credentials & preferences in ENV with the keys `MSG91_KEY`, `MSG91_SENDER_ID`, `MSG91_ROUTE`, `MSG91_COUNTRY`.

Optionally, you can use your own base uri by setting `MSG91_BASE_URI` (for resellers)

If you wan't to customize this, publish the default configuration which will create a config file `config/msg91.php`.

```bash
$ php artisan vendor:publish
Expand All @@ -47,39 +52,40 @@ $ php artisan vendor:publish

1. Send an SMS to one or more numbers. See the package config file to set up API access.

```php
```php

$result = LaravelMsg91::message(919090909090, 'This is a test message');

$result = LaravelMsg91::message(919090909090, 'This is a test message');
$result = LaravelMsg91::message(array('919090909090', '919090909091'), 'This is a test message to multiple recepients');

$result = LaravelMsg91::message(array('919090909090', '919090909091'), 'This is a test message to multiple recepients');
```

```
2. Send OTP

```php
```php

$result = LaravelMsg91::sendOtp(919090909090, 1290);
$result = LaravelMsg91::sendOtp(919090909090, 1290);

$result = LaravelMsg91::sendOtp(919090909090, 1290, "Your otp for phone verification is 1290");
```
$result = LaravelMsg91::sendOtp(919090909090, 1290, "Your otp for phone verification is 1290");
```

3. Resend OTP

```php
```php

$result = LaravelMsg91::resendOtp(919090909090);
$result = LaravelMsg91::resendOtp(919090909090);

$result = LaravelMsg91::resendOtp(919090909090, 'voice');
```
$result = LaravelMsg91::resendOtp(919090909090, 'voice');
```

3. Verify OTP
4. Verify OTP

```php
```php

$result = LaravelMsg91::verifyOtp(919090909090, 1290); // returns true or false
$result = LaravelMsg91::verifyOtp(919090909090, 1290); // returns true or false

$result = LaravelMsg91::verifyOtp(919090909090, 1290, ['raw' => true]); // returns what msg91 replies (includes error message & type)
```
$result = LaravelMsg91::verifyOtp(919090909090, 1290, ['raw' => true]); // returns what msg91 replies (includes error message & type)
```

### License

Expand Down
7 changes: 4 additions & 3 deletions src/LaravelMsg91.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ public function __construct(){
$this->auth_key = config('laravel-msg91.auth_key');
$this->sender_id = config('laravel-msg91.sender_id');
$this->route = config('laravel-msg91.route');
$this->limit_credit = config('laravel-msg91.limit_credit') ? :false;
$this->country = config('laravel-msg91.country') ?:0;
$this->guzzle = new GuzzleClient(["base_uri" => "https://control.msg91.com/api/"]);
$this->limit_credit = config('laravel-msg91.limit_credit');
$this->country = config('laravel-msg91.country');
$base_uri = config('laravel-msg91.base_uri') ? config('laravel-msg91.base_uri') : 'https://control.msg91.com/api/';
$this->guzzle = new GuzzleClient(["base_uri" => $base_uri ]);
}


Expand Down
2 changes: 2 additions & 0 deletions src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

return array(

'base_uri' => env('MSG91_BASE_URI', 'https://control.msg91.com/api/'),

/* Auth key from msg91 (required) */
'auth_key' => env('MSG91_KEY', ''),

Expand Down

0 comments on commit 81dcfa4

Please sign in to comment.