Skip to content

Commit 58a51ac

Browse files
committed
Improve sms-free
Improve sms-free Signed-off-by: Bensuperpc <[email protected]>
1 parent 71b25f0 commit 58a51ac

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

internet/sms-free.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
import sys
2525

2626
if len(sys.argv) <= 3:
27-
print("Need more arguments: <user> <API key> <Message (in quotes)>")
27+
print('Need more arguments: <user> <API key> <Message (in quotes)>')
28+
print('ex: sms-free 01234567 aBcDE012345fgH "Hello world!"')
2829
sys.exit(1)
2930

3031
user = sys.argv[1]
@@ -36,6 +37,7 @@
3637

3738
FULL_URL = URL + urllib.parse.urlencode(payload)
3839

39-
response = urllib.request.urlopen(FULL_URL)
40-
code = response.getcode()
41-
print('Return code:', code)
40+
req = urllib.request.Request(FULL_URL)
41+
with urllib.request.urlopen(req) as response:
42+
print('Return code:', response.getcode())
43+

0 commit comments

Comments
 (0)