Skip to content

Commit 636d6dd

Browse files
committed
Add guide on how to send an SMS with python
1 parent 5b148a8 commit 636d6dd

File tree

6 files changed

+317
-37
lines changed

6 files changed

+317
-37
lines changed

web/components/BlogInfo.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<v-badge
44
class="logo-badge"
55
:class="{ 'logo-badge--mobile': $vuetify.breakpoint.mdAndDown }"
6-
color="#8338ec"
6+
color="primary"
77
content="Beta"
88
>
99
<nuxt-link to="/" class="text-decoration-none d-flex">
@@ -23,11 +23,22 @@
2323
application that converts your android phone into an SMS gateway so you
2424
can send and receive SMS messages using a simple HTTP API.
2525
</p>
26+
<v-btn :href="$store.getters.getAppData.documentationUrl">
27+
<v-icon left>{{ mdiBookOpenVariant }}</v-icon>
28+
Documentation
29+
</v-btn>
2630
</div>
2731
</template>
2832

2933
<script lang="ts">
34+
import { mdiBookOpenVariant } from '@mdi/js'
35+
3036
export default {
3137
name: 'BlogInfo',
38+
data() {
39+
return {
40+
mdiBookOpenVariant,
41+
}
42+
},
3243
}
3344
</script>

web/pages/blog/index.vue

Lines changed: 56 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,50 @@
22
<v-container>
33
<v-row class="mt-16">
44
<v-col cols="12" md="9">
5-
<v-hover v-for="post in blogPosts" v-slot="{ hover }" :key="post.route">
6-
<vue-glow
7-
color="#329ef4"
8-
mode="hex"
9-
elevation="7"
10-
:intensity="hover ? 0.7 : 0"
11-
intense
12-
>
13-
<v-card :to="post.route">
14-
<v-card-title class="text-h4 text-break">{{
15-
post.title
16-
}}</v-card-title>
17-
<v-card-subtitle>
18-
<span class="text-uppercase blue--text">{{ post.date }}</span>
19-
• <span class="text-uppercase">{{ post.readTime }}</span>
20-
</v-card-subtitle>
21-
<v-card-text class="mt-n2">
22-
<p class="text--primary subtitle-1">{{ post.description }}</p>
23-
<div class="d-flex mt-n2">
24-
<v-avatar class="mb-n2">
25-
<v-img :src="post.authorImage"></v-img>
26-
</v-avatar>
27-
<div class="ml-2">
28-
<p class="subtitle-1">{{ post.authorName }}</p>
29-
<p class="mt-n5 mb-n4">
30-
{{ post.authorTwitter }}
31-
<v-icon color="#1DA1F2" small>{{ mdiTwitter }}</v-icon>
5+
<v-row>
6+
<v-col v-for="post in blogPosts" :key="post.route" cols="12" md="6">
7+
<v-hover v-slot="{ hover }">
8+
<vue-glow
9+
color="#329ef4"
10+
mode="hex"
11+
elevation="7"
12+
:intensity="hover ? 0.7 : 0"
13+
intense
14+
>
15+
<v-card :to="post.route">
16+
<v-card-title class="text-h4 text-break">{{
17+
post.title
18+
}}</v-card-title>
19+
<v-card-subtitle>
20+
<span class="text-uppercase blue--text">{{
21+
post.date
22+
}}</span>
23+
• <span class="text-uppercase">{{ post.readTime }}</span>
24+
</v-card-subtitle>
25+
<v-card-text class="mt-n2">
26+
<p class="text--primary subtitle-1">
27+
{{ post.description }}
3228
</p>
33-
</div>
34-
</div>
35-
</v-card-text>
36-
</v-card>
37-
</vue-glow>
38-
</v-hover>
29+
<div class="d-flex mt-n2">
30+
<v-avatar class="mb-n2">
31+
<v-img :src="post.authorImage"></v-img>
32+
</v-avatar>
33+
<div class="ml-2">
34+
<p class="subtitle-1">{{ post.authorName }}</p>
35+
<p class="mt-n5 mb-n4">
36+
{{ post.authorTwitter }}
37+
<v-icon color="#1DA1F2" small>{{
38+
mdiTwitter
39+
}}</v-icon>
40+
</p>
41+
</div>
42+
</div>
43+
</v-card-text>
44+
</v-card>
45+
</vue-glow>
46+
</v-hover>
47+
</v-col>
48+
</v-row>
3949
</v-col>
4050
<v-col v-if="$vuetify.breakpoint.mdAndUp" md="3">
4151
<blog-info></blog-info>
@@ -54,15 +64,26 @@ export default {
5464
return {
5565
mdiTwitter,
5666
blogPosts: [
67+
{
68+
route: '/blog/send-sms-from-android-phone-with-python',
69+
title: 'Send an SMS from your Android phone with Python',
70+
date: 'June 03, 2023',
71+
readTime: '6 min read',
72+
authorImage: require('@/assets/img/arnold.png'),
73+
description:
74+
'This article will show you how to configure your Android phone as an SMS gateway to automate sending text messages with the Python programing language.',
75+
authorName: 'Acho Arnold',
76+
authorTwitter: 'acho_arnold',
77+
},
5778
{
5879
route: '/blog/forward-incoming-sms-from-phone-to-webhook',
5980
title:
60-
'How to forward a text message (SMS) from an android phone into your webhook',
81+
'Forward a text message (SMS) from an Android phone into your webhook',
6182
date: 'April 08, 2023',
6283
readTime: '5 min read',
6384
authorImage: require('@/assets/img/arnold.png'),
6485
description:
65-
'You can now program your android phone to forward messages received on your phone to your server and trigger powerful automations with tools like zapper and IFTTFT.',
86+
'Program your android phone to forward messages received on your phone to your server and trigger powerful automations with tools like zapper and IFTTFT.',
6687
authorName: 'Acho Arnold',
6788
authorTwitter: 'acho_arnold',
6889
},
Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
<template>
2+
<v-container class="pt-8">
3+
<v-row class="mt-16">
4+
<v-col cols="12" md="9">
5+
<v-img
6+
style="border-radius: 4px"
7+
alt="blog post header image"
8+
:src="
9+
require('@/static/img/blog/send-sms-from-android-phone-with-python/header.png')
10+
"
11+
></v-img>
12+
<h1
13+
class="mt-1"
14+
:class="{
15+
'text-h2': $vuetify.breakpoint.mdAndUp,
16+
'text-h3': !$vuetify.breakpoint.mdAndUp,
17+
}"
18+
>
19+
Send an SMS from your Android phone with Python
20+
</h1>
21+
<p class="subtitle-2 mt-2">
22+
<span class="text-uppercase blue--text">{{ postDate }}</span>
23+
• <span class="text-uppercase">{{ readTime }}</span>
24+
</p>
25+
<p class="text--secondary subtitle-1 mt-2">
26+
In an era dominated by social media, instant messaging apps, and
27+
ever-evolving communication technologies, it's easy to overlook the
28+
humble yet remarkably resilient Short Message Service (SMS). Since its
29+
inception in the 1990s, SMS has stood the test of time, remaining one
30+
of the most widely used and reliable means of mobile communication.
31+
</p>
32+
<p>
33+
Whether you're a business owner looking to optimize your communication
34+
strategy, a developer seeking to integrate SMS functionality into your
35+
applications, or simply intrigued by the enduring charm of SMS, this
36+
article will explain how to setup your Android phone to send SMS
37+
messages.
38+
</p>
39+
<h3 class="text-h4 mt-8 mb-2">Prerequisites</h3>
40+
<ul>
41+
<li>Basic understanding of Python.</li>
42+
<li>An Android phone.</li>
43+
<li>
44+
<a href="https://www.python.org/" class="text-decoration-none"
45+
>Python</a
46+
>
47+
installed on your computer.
48+
</li>
49+
</ul>
50+
<h3 class="text-h4 mt-8 mb-2">Step 1: Get your API Key</h3>
51+
<p>
52+
Create an account on
53+
<nuxt-link class="text-decoration-none" to="/">httpsms.com</nuxt-link>
54+
and copy your API key from the settings page
55+
<nuxt-link class="text-decoration-none" to="/settings"
56+
>https://httpsms.com/settings</nuxt-link
57+
>
58+
</p>
59+
<vue-glow
60+
color="#329ef4"
61+
mode="hex"
62+
elevation="14"
63+
:intensity="1.07"
64+
intense
65+
>
66+
<v-img
67+
style="border-radius: 4px"
68+
alt="httpsms.com settings page"
69+
:src="
70+
require('@/static/img/blog/forward-incoming-sms-from-phone-to-webhook/settings.png')
71+
"
72+
></v-img>
73+
</vue-glow>
74+
<h3 class="text-h4 mb-4 mt-16">
75+
Step 2: Install the httpSMS android app
76+
</h3>
77+
<p>
78+
<a
79+
target="_blank"
80+
class="text-decoration-none"
81+
href="https://github.com/NdoleStudio/httpsms/releases/latest/download/HttpSms.apk"
82+
>⬇️ Download and install</a
83+
>
84+
the httpSMS android app on your phone and sign in using your API KEY
85+
which you copied above. This app listens for SMS messages received on
86+
your android phone.
87+
</p>
88+
<v-alert type="info" outlined>
89+
Make sure to enter your phone number in the international format e.g
90+
+18005550199 when authenticating with the httpSMS Android app.
91+
</v-alert>
92+
<v-img
93+
style="border-radius: 4px"
94+
alt="httpsms android app"
95+
height="800"
96+
contain
97+
:src="
98+
require('@/static/img/blog/forward-incoming-sms-from-phone-to-webhook/android-app.png')
99+
"
100+
></v-img>
101+
<h3 class="text-h4 mt-12">Step 3: Writing the code</h3>
102+
<p>
103+
Now that you have setup your android phone correctly on httpSMS, you
104+
can write the python code below in a new file named
105+
<code>send_sms.py</code>. This code will send and SMS and after
106+
running the script via your Android phone to the recipient phone
107+
number specified in the <code>payload</code>.
108+
</p>
109+
<v-alert type="info" outlined class="mt-2 mb-4">
110+
Make sure to use the correct <code>api_key</code> from step 1 and also
111+
use the correct <code>to</code> and <code>from</code> phone numbers in
112+
the <code>payload</code> variable.
113+
</v-alert>
114+
<pre v-highlight class="python w-full mb-n9">
115+
<code>import requests
116+
import json
117+
118+
api_key = "" # Get API Key from https://httpsms.com/settings
119+
120+
url = 'https://api.httpsms.com/v1/messages/send'
121+
122+
headers = {
123+
'x-api-key': api_key,
124+
'Accept': 'application/json',
125+
'Content-Type': 'application/json'
126+
}
127+
128+
payload = {
129+
"content": "This is a sample text message sent via python",
130+
"from": "+18005550199", # This is the phone number of your android phone */
131+
"to": "+18005550100" # This is the recipient phone number */
132+
}
133+
134+
response = requests.post(url, headers=headers, data=json.dumps(payload))
135+
136+
print(json.dumps(response.json(), indent=4))
137+
</code>
138+
</pre>
139+
<p>
140+
Run the code above with the command
141+
<code>python send_sms.py</code> and check the phone specified in the
142+
<code>to</code> field of the <code>payload</code> to verify that the
143+
message has been received successfully.
144+
</p>
145+
<v-img
146+
style="border-radius: 4px"
147+
alt="httpsms android app"
148+
height="800"
149+
contain
150+
:src="
151+
require('@/static/img/blog/send-sms-from-android-phone-with-python/sms-sent.png')
152+
"
153+
></v-img>
154+
<h3 class="text-h4 mt-12">Conclusion</h3>
155+
<p>
156+
Congratulations, you have successfully configured your android phone
157+
to send SMS messages via python. You can now reuse this code to send
158+
SMS messages from your python applications.
159+
</p>
160+
<p>
161+
If you are also interested in forwarding incoming SMS from your
162+
android phone to your server, checkout our
163+
<nuxt-link
164+
to="/blog/forward-incoming-sms-from-phone-to-webhook"
165+
class="text-decoration-none"
166+
>SMS forwarding guide.</nuxt-link
167+
>
168+
</p>
169+
<p>Until the next time✌️</p>
170+
<div class="d-flex mb-6 mt-8">
171+
<v-avatar class="mb-n2">
172+
<v-img :src="authorImage"></v-img>
173+
</v-avatar>
174+
<div class="ml-2">
175+
<p class="subtitle-1 mb-n1">{{ authorName }}</p>
176+
<a
177+
class="mb-n4 text-decoration-none text--primary"
178+
href="https://twitter.com/acho_arnold"
179+
>
180+
{{ authorTwitter }}
181+
<v-icon color="#1DA1F2" small>{{ mdiTwitter }}</v-icon>
182+
</a>
183+
</div>
184+
</div>
185+
<v-divider class="mx-16"></v-divider>
186+
<div class="text-center mt-8 mb-4">
187+
<back-button></back-button>
188+
</div>
189+
</v-col>
190+
<v-col v-if="$vuetify.breakpoint.mdAndUp" md="3">
191+
<blog-info></blog-info>
192+
</v-col>
193+
</v-row>
194+
</v-container>
195+
</template>
196+
197+
<script lang="ts">
198+
import { mdiTwitter } from '@mdi/js'
199+
export default {
200+
name: 'SendSmsFromAndroidPhoneWithPython',
201+
layout: 'website',
202+
data() {
203+
return {
204+
mdiTwitter,
205+
authorImage: require('@/assets/img/arnold.png'),
206+
authorName: 'Acho Arnold',
207+
postDate: 'June 03, 2023',
208+
readTime: '6 min read',
209+
authorTwitter: 'acho_arnold',
210+
}
211+
},
212+
head() {
213+
return {
214+
title: 'Send an SMS from your Android phone with Python - httpSMS',
215+
meta: [
216+
{
217+
hid: 'og:title',
218+
property: 'og:title',
219+
content: 'Send an SMS from your Android phone with Python',
220+
},
221+
{
222+
hid: 'og:description',
223+
property: 'og:description',
224+
content:
225+
'Configure your Android phone as an SMS gateway to automate sending text messages with the Python programing language.',
226+
},
227+
{
228+
hid: 'og:image',
229+
property: 'og:image',
230+
content:
231+
'https://httpsms.com/img/blog/send-sms-from-android-phone-with-python/header.png',
232+
},
233+
{
234+
hid: 'twitter:card',
235+
name: 'twitter:card',
236+
content: 'summary_large_image',
237+
},
238+
{
239+
hid: 'og:url',
240+
property: 'og:url',
241+
content:
242+
'https://httpsms.com/blog/send-sms-from-android-phone-with-python',
243+
},
244+
],
245+
}
246+
},
247+
}
248+
</script>

0 commit comments

Comments
 (0)