Skip to content

Commit 81dcfa4

Browse files
committed
Option to customize the base_uri - #12
1 parent 1d961a5 commit 81dcfa4

File tree

3 files changed

+31
-22
lines changed

3 files changed

+31
-22
lines changed

README.md

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Add `robincsamuel/laravel-msg91` to your composer requirements:
2626

2727
Now run `composer update`
2828

29-
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:
29+
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:
3030

3131
```php
3232
RobinCSamuel\LaravelMsg91\LaravelMsg91ServiceProvider::class
@@ -37,7 +37,12 @@ Next, locate the `aliases` key and add the following line:
3737
```php
3838
'LaravelMsg91' => RobinCSamuel\LaravelMsg91\Facades\LaravelMsg91::class,
3939
```
40-
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`.
40+
41+
Put the credentials & preferences in ENV with the keys `MSG91_KEY`, `MSG91_SENDER_ID`, `MSG91_ROUTE`, `MSG91_COUNTRY`.
42+
43+
Optionally, you can use your own base uri by setting `MSG91_BASE_URI` (for resellers)
44+
45+
If you wan't to customize this, publish the default configuration which will create a config file `config/msg91.php`.
4146

4247
```bash
4348
$ php artisan vendor:publish
@@ -47,39 +52,40 @@ $ php artisan vendor:publish
4752

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

50-
```php
55+
```php
56+
57+
$result = LaravelMsg91::message(919090909090, 'This is a test message');
5158

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

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

56-
```
5763
2. Send OTP
5864

59-
```php
65+
```php
6066

61-
$result = LaravelMsg91::sendOtp(919090909090, 1290);
67+
$result = LaravelMsg91::sendOtp(919090909090, 1290);
6268

63-
$result = LaravelMsg91::sendOtp(919090909090, 1290, "Your otp for phone verification is 1290");
64-
```
69+
$result = LaravelMsg91::sendOtp(919090909090, 1290, "Your otp for phone verification is 1290");
70+
```
6571

6672
3. Resend OTP
6773

68-
```php
74+
```php
6975

70-
$result = LaravelMsg91::resendOtp(919090909090);
76+
$result = LaravelMsg91::resendOtp(919090909090);
7177

72-
$result = LaravelMsg91::resendOtp(919090909090, 'voice');
73-
```
78+
$result = LaravelMsg91::resendOtp(919090909090, 'voice');
79+
```
7480

75-
3. Verify OTP
81+
4. Verify OTP
7682

77-
```php
83+
```php
7884

79-
$result = LaravelMsg91::verifyOtp(919090909090, 1290); // returns true or false
85+
$result = LaravelMsg91::verifyOtp(919090909090, 1290); // returns true or false
8086

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

8490
### License
8591

src/LaravelMsg91.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ public function __construct(){
6262
$this->auth_key = config('laravel-msg91.auth_key');
6363
$this->sender_id = config('laravel-msg91.sender_id');
6464
$this->route = config('laravel-msg91.route');
65-
$this->limit_credit = config('laravel-msg91.limit_credit') ? :false;
66-
$this->country = config('laravel-msg91.country') ?:0;
67-
$this->guzzle = new GuzzleClient(["base_uri" => "https://control.msg91.com/api/"]);
65+
$this->limit_credit = config('laravel-msg91.limit_credit');
66+
$this->country = config('laravel-msg91.country');
67+
$base_uri = config('laravel-msg91.base_uri') ? config('laravel-msg91.base_uri') : 'https://control.msg91.com/api/';
68+
$this->guzzle = new GuzzleClient(["base_uri" => $base_uri ]);
6869
}
6970

7071

src/config/config.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
return array(
44

5+
'base_uri' => env('MSG91_BASE_URI', 'https://control.msg91.com/api/'),
6+
57
/* Auth key from msg91 (required) */
68
'auth_key' => env('MSG91_KEY', ''),
79

0 commit comments

Comments
 (0)