|
1 |
| -Sparrow SMS Laravel Package |
2 |
| -============================= |
3 |
| - |
4 |
| -[](https://github.com/TheBikramLama/sparrow/releases) |
5 |
| - |
6 |
| -[](https://packagist.org/packages/thebikramlama/sparrow) |
7 |
| - |
8 |
| -Sparrow SMS Laravel Package can be used to send SMS via Sparrow SMS or query account's credits. |
9 |
| - |
10 |
| -## Getting Started |
11 |
| - |
12 |
| -This package can be installed through Composer. |
13 |
| - |
14 |
| -```bash |
15 |
| -composer require thebikramlama/sparrow |
16 |
| -``` |
17 |
| - |
18 |
| -Publish `sparrow.php` config file for customization |
19 |
| -```bash |
20 |
| -php artisan vendor:publish --provider="Thebikramlama\Sparrow\SparrowServiceProvider" |
21 |
| -``` |
22 |
| - |
23 |
| -## How to send an SMS |
24 |
| - |
25 |
| -After the installation is complete, `Sparrow` alias is generated by default. |
26 |
| - |
27 |
| -### Using the default Alias |
28 |
| -```php |
29 |
| -// Using Default |
30 |
| -use Sparrow; |
31 |
| -``` |
32 |
| - |
33 |
| -### Send an SMS |
34 |
| -```php |
35 |
| -$from = 'InfoSms'; // Setting FROM provided by Sparrow |
36 |
| -$access_token = 'YOUR_ACCESS_TOKEN'; // Setting Access Token provided by Sparrow |
37 |
| - |
38 |
| -$to = '9801234567'; // Setting Phone Number |
39 |
| -$message = 'Test message from Sparrow.'; // Setting Message |
40 |
| - |
41 |
| -// Send the message |
42 |
| -$sms_message = Sparrow::send($to, $message, $from, $access_token); |
43 |
| -// This will return a pseudo JSON response, you will need to json_decode it. |
44 |
| -``` |
45 |
| - |
46 |
| -## Getting available Credits |
47 |
| -```php |
48 |
| -$access_token = 'YOUR_ACCESS_TOKEN'; // Setting Access Token provided by Sparrow |
49 |
| - |
50 |
| -// Query Credits |
51 |
| -$credits = Sparrow::credits($access_token); |
52 |
| -echo 'Available credits: '. json_decode($credits)->credits_available; // Available credits: 1500 |
53 |
| -``` |
54 |
| - |
55 |
| -## Customization |
56 |
| -Make sure you have published `sparrow.php` config file |
57 |
| -```bash |
58 |
| -php artisan vendor:publish --provider="Thebikramlama\Sparrow\SparrowServiceProvider" |
59 |
| -``` |
60 |
| -You can find the `sparrow.php` config file under `config/sparrow.php` inside your laravel project. |
61 |
| - |
62 |
| -You can edit the file as per your need. |
63 |
| -```php |
64 |
| -// Your Sparrow SMS Access Token here. |
65 |
| -'access_token' => 'YOUR_ACCESS_TOKEN', |
66 |
| -// Identity Provided by Sparrow SMS |
67 |
| -'from' => 'FROM', |
68 |
| -``` |
69 |
| - |
70 |
| -After updating the `sparrow.php` config file you can call `Sparrow` methods with lesser arguments. |
71 |
| - |
72 |
| -Example: |
73 |
| -```php |
74 |
| -$sms_message = Sparrow::send('98081234567', 'Test Messsage'); // From and Access token are optional |
75 |
| -$credits = Sparrow::credits(); // Access token is optional |
76 |
| -``` |
77 |
| - |
78 |
| -## Credits |
79 |
| -- [Bikram Lama](https://github.com/TheBikramLama) |
80 |
| - |
81 |
| -## License |
82 |
| - |
83 |
| -The MIT License (MIT). Please see [License File](LICENSE) for more information. |
| 1 | +Sparrow SMS Laravel Package |
| 2 | +============================= |
| 3 | + |
| 4 | +[](https://github.com/TheBikramLama/sparrow/releases) |
| 5 | + |
| 6 | +[](https://packagist.org/packages/thebikramlama/sparrow) |
| 7 | + |
| 8 | +Sparrow SMS Laravel Package can be used to send SMS via Sparrow SMS or query account's credits. |
| 9 | + |
| 10 | +## Getting Started |
| 11 | + |
| 12 | +This package can be installed through Composer. |
| 13 | + |
| 14 | +```bash |
| 15 | +composer require thebikramlama/sparrow |
| 16 | +``` |
| 17 | + |
| 18 | +Publish `sparrow.php` config file for customization |
| 19 | +```bash |
| 20 | +php artisan vendor:publish --provider="Thebikramlama\Sparrow\SparrowServiceProvider" |
| 21 | +``` |
| 22 | + |
| 23 | +## How to send an SMS |
| 24 | + |
| 25 | +After the installation is complete, `Sparrow` alias is generated by default. |
| 26 | + |
| 27 | +### Using the default Alias |
| 28 | +```php |
| 29 | +// Using Default |
| 30 | +use Sparrow; |
| 31 | +``` |
| 32 | + |
| 33 | +### Send an SMS |
| 34 | +```php |
| 35 | +$from = 'InfoSms'; // Setting FROM provided by Sparrow |
| 36 | +$access_token = 'YOUR_ACCESS_TOKEN'; // Setting Access Token provided by Sparrow |
| 37 | + |
| 38 | +$to = '9801234567'; // Setting Phone Number |
| 39 | +$message = 'Test message from Sparrow.'; // Setting Message |
| 40 | + |
| 41 | +// Send the message |
| 42 | +$sms_message = Sparrow::send($to, $message, $from, $access_token); |
| 43 | +// This will return a pseudo JSON response, you will need to json_decode it. |
| 44 | +``` |
| 45 | + |
| 46 | +## Getting available Credits |
| 47 | +```php |
| 48 | +$access_token = 'YOUR_ACCESS_TOKEN'; // Setting Access Token provided by Sparrow |
| 49 | + |
| 50 | +// Query Credits |
| 51 | +$credits = Sparrow::credits($access_token); |
| 52 | +echo 'Available credits: '. json_decode($credits)->credits_available; // Available credits: 1500 |
| 53 | +``` |
| 54 | + |
| 55 | +## Customization |
| 56 | +Make sure you have published `sparrow.php` config file |
| 57 | +```bash |
| 58 | +php artisan vendor:publish --provider="Thebikramlama\Sparrow\SparrowServiceProvider" |
| 59 | +``` |
| 60 | +You can find the `sparrow.php` config file under `config/sparrow.php` inside your laravel project. |
| 61 | + |
| 62 | +You can edit the file as per your need. |
| 63 | +```php |
| 64 | +// Your Sparrow SMS Access Token here. |
| 65 | +'access_token' => 'YOUR_ACCESS_TOKEN', |
| 66 | +// Identity Provided by Sparrow SMS |
| 67 | +'from' => 'FROM', |
| 68 | +``` |
| 69 | + |
| 70 | +After updating the `sparrow.php` config file you can call `Sparrow` methods with lesser arguments. |
| 71 | + |
| 72 | +Example: |
| 73 | +```php |
| 74 | +$sms_message = Sparrow::send('98081234567', 'Test Messsage'); // From and Access token are optional |
| 75 | +$credits = Sparrow::credits(); // Access token is optional |
| 76 | +``` |
| 77 | + |
| 78 | +## Credits |
| 79 | +- [Bikram Lama](https://github.com/TheBikramLama) |
| 80 | + |
| 81 | +## License |
| 82 | + |
| 83 | +The MIT License (MIT). Please see [License File](LICENSE) for more information. |
0 commit comments