Created
May 14, 2020 12:26
-
-
Save yuta-imai/50941a7539c51443f1b4f05a87c6a59b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import urllib3 | |
api = 'https://api.soracom.io/v1' | |
auth_key_id = "keyId-xxxxxxx" | |
auth_key = "secret-xxxxxxxx" | |
target_imsi = '111111111111111' | |
http = urllib3.PoolManager() | |
auth_result = http.request( | |
'POST', | |
api + '/auth', | |
body = json.dumps({'authKeyId':auth_key_id, 'authKey':auth_key}), | |
headers={'Content-Type': 'application/json'} | |
) | |
credential =json.loads(auth_result.data.decode('utf-8')) | |
print(credential) | |
sms_send_result = http.request( | |
'POST', | |
api + '/subscribers/{}/send_sms'.format(target_imsi), | |
body = json.dumps({'encodingType':2, 'payload':'Hello World.'}), | |
headers={ | |
'Content-Type': 'application/json', | |
'x-soracom-api-key': credential['apiKey'], | |
'x-soracom-token': credential['token'] | |
} | |
) | |
print(json.loads(sms_send_result.data.decode('utf-8'))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment