You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+46-31Lines changed: 46 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,9 +28,9 @@ This is a **PHP Client** for [Msg91 APIs](https://docs.msg91.com/collection/msg9
28
28
## Table of Contents
29
29
30
30
-[Installation](#installation)
31
-
-[Configuration](#configuration)
32
31
-[Usage](#usage)
33
32
-[Create a Client](#create-a-client)
33
+
-[Configuration](#configuration)
34
34
-[OTP and SMS Services](#otp-and-sms-services)
35
35
-[Examples](#examples)
36
36
-[Managing OTPs](#managing-otps)
@@ -52,34 +52,6 @@ The packages is available on [Packagist](https://packagist.org/packages/craftsys
52
52
composer require craftsys/msg91-php
53
53
```
54
54
55
-
## Configuration
56
-
57
-
The module is configurable to your specific needs where you need to set default options for APIs like the default OTP message format, retry method etc.
58
-
59
-
An example configuration might look something like this:
60
-
61
-
```php
62
-
$config = [
63
-
'key' => "123456789012345678901234",
64
-
'otp_message' => "G: ##OTP## is your verification code".
| key | string | The authentication key for Msg91 apis (**required**) | null |
73
-
| otp_message | ?string | Message template used when an OTP is sent. The **##OTP##** placeholder is required | Your OTP is ##OTP## |
74
-
| resend_otp_method | ?enum("text", "voice") | Default method when resending an OTP when previous attempt of OTP send/verification failed. It can take one of "text" or "voice" values. | text |
75
-
| from | ?string | The default name for sender. This is used the **From** in messaging applications. It's value can only contain alphanumeric values. | null |
76
-
| otp_length | ?number | Length of the generated OTP by Msg91 api when you are not generating OTPs on our end.. This can be between [4, 9]| 4 |
77
-
| otp_expiry | ?number | Duration (in minutes) for which the OTP is valid. | 5 |
78
-
| route | ?number |[Route](https://help.msg91.com/article/64-what-is-the-difference-between-transactional-promotional-and-sendotp-route) for SMS | null |
79
-
| unicode | ?number | Set to this 1 if all your message contains unicode characters | 0 |
80
-
81
-
**NOTE**: Setting any if these values as null will override the default values to null too. And so, the default values from Msg91 APIs will be used. For example, setting the `otp_message` to `null` will let use "Your verification code is ##OTP##" which the default from [APIS](https://docs.msg91.com/collection/msg91-api-integration/5/send-otp-message/TZ6HN0YI)
82
-
83
55
## Usage
84
56
85
57
If you're using Composer, make sure the autoloader is included in your project's bootstrap file:
@@ -88,7 +60,7 @@ If you're using Composer, make sure the autoloader is included in your project's
88
60
require_once "vendor/autoload.php";
89
61
```
90
62
91
-
Once you have [Configured](#configuration), client can be initialised by passing a configuration object to the constructor. The configuration in the constructor is optional.
63
+
Now the client can be initialised by passing a [configured](#configuration) object to the constructor.
92
64
93
65
```php
94
66
$config = [
@@ -105,8 +77,19 @@ The package in distributed under `Craftsys\Msg91` namespace which can used if yo
105
77
use Craftsys\Msg91\Client;
106
78
107
79
// somewhere in this source file where you need the client
Continue reading to learn more about configuration and available method on `opt` and `sms` services with examples.
92
+
110
93
111
94
### Create a Client
112
95
@@ -128,6 +111,38 @@ You can also pass a custom `GuzzleHttp\Client` as the second argument on the Cli
128
111
```php
129
112
$client = new Craftsys\Msg91\Client($config, new GuzzleHttp\Client());
130
113
```
114
+
115
+
116
+
### Configuration
117
+
118
+
The module is configurable to your specific needs where you need to set default options for APIs like the default OTP message format, retry method etc.
119
+
120
+
An example configuration might look something like this:
121
+
122
+
```php
123
+
$config = [
124
+
'key' => "123456789012345678901234",
125
+
'otp_message' => "G: ##OTP## is your verification code".
| key | string | The authentication key for Msg91 apis (**required**) | null |
134
+
| otp_message | ?string | Message template used when an OTP is sent. The **##OTP##** placeholder is required | Your OTP is ##OTP## |
135
+
| resend_otp_method | ?enum("text", "voice") | Default method when resending an OTP when previous attempt of OTP send/verification failed. It can take one of "text" or "voice" values. | text |
136
+
| from | ?string | The default name for sender. This is used the **From** in messaging applications. It's value can only contain alphanumeric values. | null |
137
+
| otp_length | ?number | Length of the generated OTP by Msg91 api when you are not generating OTPs on our end.. This can be between [4, 9]| 4 |
138
+
| otp_expiry | ?number | Duration (in minutes) for which the OTP is valid. | 5 |
139
+
| route | ?number |[Route](https://help.msg91.com/article/64-what-is-the-difference-between-transactional-promotional-and-sendotp-route) for SMS | null |
140
+
| unicode | ?number | Set to this 1 if all your message contains unicode characters | 0 |
141
+
142
+
**NOTE**: Setting any if these values as null will override the default values to null too. And so, the default values from Msg91 APIs will be used. For example, setting the `otp_message` to `null` will let use "Your verification code is ##OTP##" which the default from [APIS](https://docs.msg91.com/collection/msg91-api-integration/5/send-otp-message/TZ6HN0YI)
143
+
144
+
145
+
131
146
### OTP and SMS Services
132
147
133
148
After a client has been created, you can access `otp` and `sms` services to send OTPs and SMSs respectivily.
0 commit comments