|
2 | 2 |  |
3 | 3 |
|
4 | 4 |
|
5 | | -# Android SMS Gateway (PHP API Samples) |
| 5 | +# Android SMS Gateway (PHP) |
6 | 6 |
|
7 | 7 | Android SMS Gateway transforms your Android smartphone into an SMS gateway. It is a lightweight application that enables you to send SMS messages programmatically via an API, making it ideal for integrating SMS functionality into your applications or services. |
8 | 8 |
|
9 | 9 |
|
10 | | -https://sms.rootscratch.com/ |
11 | | -## Features |
12 | 10 |
|
13 | | -- Send (Single / Bulk) Messages |
14 | | -- Receive Messages (SMS) |
15 | | -- Send / Get USSD Requests |
16 | | -- Manage Contacts |
| 11 | + |
| 12 | +## Installation |
| 13 | + |
| 14 | +To install the rootscratch/sms via Composer, run the following command: |
| 15 | + |
| 16 | +```bash |
| 17 | + composer require rootscratch/sms |
| 18 | +``` |
| 19 | + |
| 20 | +## Usage/Examples |
| 21 | +To use the Rootscratch SMS in your PHP project, include the Composer autoloader: |
| 22 | + |
| 23 | + |
| 24 | +```php |
| 25 | +require_once __DIR__ . '/vendor/autoload.php'; |
| 26 | +use Rootscratch\SMS\Configuration; |
| 27 | +$configuration = new Configuration(); |
| 28 | +// Set API Key |
| 29 | +Configuration::setApiKey('your_api_key'); |
| 30 | +``` |
| 31 | + |
| 32 | +## Send Single SMS |
| 33 | +```php |
| 34 | +use Rootscratch\SMS\Send; |
| 35 | +$sendMessage = new Send(); |
| 36 | +$send_single = $sendMessage->sendSingleMessage('mobile_number', 'Message'); |
| 37 | +echo json_encode($send_single, JSON_PRETTY_PRINT); |
| 38 | +``` |
| 39 | + |
| 40 | +## Send Bulk Message |
| 41 | +```php |
| 42 | +$send_bulk = $sendMessage->sendMessages([ |
| 43 | + [ |
| 44 | + "number" => "6391234567890", |
| 45 | + "message" => "Message 1" |
| 46 | + ], |
| 47 | + [ |
| 48 | + "number" => "6391234567891", |
| 49 | + "message" => "Message 2" |
| 50 | + ] |
| 51 | +]); |
| 52 | +echo json_encode($send_bulk, JSON_PRETTY_PRINT); |
| 53 | +``` |
| 54 | + |
| 55 | +## Send MMS Sample |
| 56 | + |
| 57 | +- Use All Sims = sendMessages(messages = array, option = USE_ALL_SIMS) |
| 58 | +- Use All Devices = sendMessages(messages = array, option = USE_ALL_DEVICES) |
| 59 | +- Use Specified Devices = sendMessages(messages = array, option = USE_SPECIFIED, devices = array) |
| 60 | + |
| 61 | +```php |
| 62 | +/** |
| 63 | + * Send MMS Sample |
| 64 | + * Use All Sims = sendMessages(messages = array, option = USE_ALL_SIMS) |
| 65 | + * Use All Devices = sendMessages(messages = array, option = USE_ALL_DEVICES) |
| 66 | + * Use Specified Devices = sendMessages(messages = array, option = USE_SPECIFIED, devices = array) |
| 67 | + */ |
| 68 | + |
| 69 | +$send_bulk_mms = $sendMessage->sendMessages([ |
| 70 | + [ |
| 71 | + "number" => "639123456789", |
| 72 | + "message" => "Test 1", |
| 73 | + "type" => "mms", |
| 74 | + "attachments" => 'https://sample.com/1.png' |
| 75 | + ], |
| 76 | + [ |
| 77 | + "number" => "639123456789", |
| 78 | + "message" => "Test 2", |
| 79 | + "type" => "mms", |
| 80 | + "attachments" => 'https://sample.com/1.png' |
| 81 | + ] |
| 82 | +]); |
| 83 | +echo json_encode($send_bulk_mms, JSON_PRETTY_PRINT); |
| 84 | +``` |
| 85 | + |
| 86 | +## Send Message To Contacts List |
| 87 | +Send a message on schedule to contacts in contacts list with ID of 1. |
| 88 | + |
| 89 | +- Send a message on schedule to contacts in contacts list with ID of 1. |
| 90 | +sendMessageToContactsList(1, "Test", null, null, strtotime("+2 minutes")); |
| 91 | + |
| 92 | +```php |
| 93 | +$send_contact_list = $sendMessage->sendMessageToContactsList(1, 'Via Contact List!', Configuration::USE_SPECIFIED, [4]); |
| 94 | +echo json_encode($send_contact_list, JSON_PRETTY_PRINT); |
| 95 | +``` |
| 96 | + |
| 97 | +## Send USSD Request |
| 98 | +Send a USSD request using default SIM of Device ID 1. |
| 99 | + |
| 100 | +```php |
| 101 | +$send_ussd = $sendMessage->sendUssdRequest('*150#', 1); |
| 102 | +echo json_encode($send_ussd, JSON_PRETTY_PRINT); |
| 103 | +``` |
| 104 | +Send a USSD request using SIM in slot 1 of Device ID 1 |
| 105 | +```php |
| 106 | +$send_ussd = $sendMessage->sendUssdRequest('*150#', 1, 0); |
| 107 | +echo json_encode($send_ussd, JSON_PRETTY_PRINT); |
| 108 | +``` |
| 109 | +Send a USSD request using SIM in slot 2 of Device ID 1. |
| 110 | +```php |
| 111 | +$send_ussd = $sendMessage->sendUssdRequest('*150#', 1, 1); |
| 112 | +echo json_encode($send_ussd, JSON_PRETTY_PRINT); |
| 113 | +``` |
| 114 | + |
| 115 | +## Resend SMS |
| 116 | +```php |
| 117 | +/** |
| 118 | + * Resend SMS Sample |
| 119 | + * Resend Message By ID = resendMessageByID(id = int) |
| 120 | + * Resend Messages By Group ID = resendMessagesByGroupID(group_id = string, status = string) |
| 121 | + */ |
| 122 | + |
| 123 | +use Rootscratch\SMS\Resend; |
| 124 | + |
| 125 | +$resend = new Resend(); |
| 126 | + |
| 127 | +$resend_by_id = $resend->resendMessagesByGroupID('MZ7QabWteHWfSkjkgX67acc67bcc2048.73874662', 'Failed'); |
| 128 | +echo json_encode($resend_by_id, JSON_PRETTY_PRINT); |
| 129 | +``` |
17 | 130 |
|
18 | 131 |
|
19 | 132 | ## Support |
|
0 commit comments