# -*- coding: utf-8 -*-
from urllib import request
import json
token = 'Your token' #Your first token must be generated on our plateform at https://my.smsfactor.com/developers/api-tokens
content = 'Test API python'
numbers = ['33601020304', '33612345678']
recipients = [];
for number in numbers:
recipients.append({'value': number})
data = {
'sms': {
'message': {
'text': content
},
'recipients': {
'gsm': recipients
}
}
}
data = json.dumps(data).encode('utf-8')
req = request.Request('https://api.smsfactor.com/send', data)
req.add_header('Accept', 'application/json')
req.add_header('Authorization', "Bearer %s" % token)
with request.urlopen(req, data) as f:
print(f.read().decode('utf-8'))