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
{{ message }}
This repository was archived by the owner on Dec 18, 2023. It is now read-only.
Add your Mobtexting Auth Token, and From Number (optional) to your `config/services.php`:
39
-
40
-
```php
41
-
// config/services.php
42
-
...
43
-
'mobtexting' => [
44
-
'username' => env('MOBTEXTING_USERNAME'), // optional when using auth token
45
-
'password' => env('MOBTEXTING_PASSWORD'), // optional when using auth token
46
-
'token' => env('MOBTEXTING_AUTH_TOKEN'), // optional when using username and password
47
-
'from' => env('TWILIO_FROM'), // optional
48
-
],
49
-
...
21
+
composer require mobtexting/mobtexting-php
50
22
```
51
23
52
24
## Usage
53
25
54
-
Now you can use the channel in your `via()` method inside the notification:
55
-
56
-
```php
57
-
use NotificationChannels\Mobtexting\MobtextingChannel;
58
-
use NotificationChannels\Mobtexting\MobtextingSmsMessage;
59
-
use Illuminate\Notifications\Notification;
60
-
61
-
class AccountApproved extends Notification
62
-
{
63
-
public function via($notifiable)
64
-
{
65
-
return [MobtextingChannel::class];
66
-
}
67
-
68
-
public function toMobtexting($notifiable)
69
-
{
70
-
return (new MobtextingSmsMessage())
71
-
->text("Your {$notifiable->service} account was approved!");
72
-
}
73
-
}
74
-
```
75
-
76
-
In order to let your Notification know which phone are you sending/calling to, the channel will look for the `phone_number` attribute of the Notifiable model. If you want to override this behaviour, add the `routeNotificationForMobtexting` method to your Notifiable model.
26
+
### Send an SMS
77
27
78
28
```php
79
-
public function routeNotificationForMobtexting()
80
-
{
81
-
return '+1234567890';
82
-
}
29
+
// Send an SMS using Twilio's REST API and PHP
30
+
<?php
31
+
$token = "YYYYYY"; // Your Auth Token from www.twilio.com/console
32
+
33
+
$client = new Mobtexting\Client($token);
34
+
$message = $client->messages->send(
35
+
'1234567890', // Text this number
36
+
array(
37
+
'from' => '9991231234', // From a valid Twilio number
38
+
'text' => 'Hello from Twilio!'
39
+
)
40
+
);
41
+
42
+
print_r($message->json());
83
43
```
84
44
85
-
### Available Message methods
86
-
87
-
#### MobtextingSmsMessage
88
-
89
-
-`from('')`: Accepts a phone to use as the notification sender.
90
-
-`text('')`: Accepts a string value for the notification body.
91
-
-`to('')`: Accepts a string value for the notification to (over writes default).
0 commit comments