|
| 1 | +## Send Text Message via TextBelt |
| 2 | +### Description |
| 3 | +The aim is to anonymously send a text message to a mobile number programmatically. |
| 4 | + |
| 5 | +### Library used |
| 6 | +* [requests](https://2.python-requests.org/en/v2.7.0/) |
| 7 | + |
| 8 | +### About TextBelt API: |
| 9 | +*Textbelt* is an SMS API that is built for developers who just want to send and receive SMS. Sending an SMS is a simple thing. The API is correspondingly simple, without requiring account configuration, logins, or extra recurring billing. |
| 10 | + |
| 11 | +The `https://textbelt.com/text` endpoint accepts a POST request with the following parameters: |
| 12 | + |
| 13 | +* `phone`: A phone number. If you're in the U.S. or Canada, you can just send a normal 10-digit phone number with area code. Outside the U.S., it is best to send the phone number in E.164 format with your country code. |
| 14 | +* `message`: The content of your SMS. |
| 15 | +* `key`: Your API key (use textbelt to send a free message). |
| 16 | + |
| 17 | +Every programming language has a way to send an HTTP POST request. Instead of installing a special Textbelt library, just send a POST request. |
| 18 | + |
| 19 | +*Response* |
| 20 | + |
| 21 | +The /text endpoint will respond with JSON: |
| 22 | +* `success`: Whether the message was successfully sent (true/false). |
| 23 | +* `quotaRemaining`: The amount of credit remaining on your key. |
| 24 | +* `textId`: The ID of the sent message, used for looking up its status. Only present when success=true. Use this to check SMS delivery status. |
| 25 | +* `error`: A string describing the problem. Only present when success=false. |
| 26 | + |
| 27 | +### Parameters used and their Significance: |
| 28 | +* phoneNumber : The 10 digit phone number given by the user. |
| 29 | +* message : The message which the user wants to sent to the given phoneNumber. |
| 30 | + |
| 31 | +### Pre-requisites: |
| 32 | +Install requests library via pip/pip3 |
| 33 | + |
| 34 | +`>> pip3 install requests` |
| 35 | + |
| 36 | +### Usage: |
| 37 | +`>> python send_message.py` |
| 38 | + |
| 39 | +### I/O: |
| 40 | + |
| 41 | +``` |
| 42 | +Enter your 10 digit phone number: $(phone_number) |
| 43 | +
|
| 44 | +Enter your message: $(message) |
| 45 | +
|
| 46 | +Message successfully sent! |
| 47 | +``` |
| 48 | + |
| 49 | +<img src="ScreenShots/output.png" height=50 width=300> |
| 50 | +</br></br> |
| 51 | +<img src="ScreenShots/message_received.jpg" height=200 width=100> |
| 52 | + |
| 53 | + |
| 54 | +**OR (if sending failed)** |
| 55 | + |
| 56 | +``` |
| 57 | +Sorry...Message cannot be sent |
| 58 | +Only one test text message is allowed per day. |
| 59 | +``` |
0 commit comments