def send_sms(provider, src, dst, txt, uid, uname, pword):
import urllib, json, base64, requests
if provider=='plivo':
data = json.dumps({'src': src, 'dst': dst, 'text': txt})
url = settings.plivo_send % uname
headers = {'Content-Type': 'application/json',
'Authorization': 'Basic %s' % base64.b64encode('%s:%s' % (uname, pword))}
if provider=='twilio':
data = urllib.urlencode({'From': '+%s' % src, 'To': dst, 'Body': txt})
url = settings.twilio_send % uname
headers = {'Authorization': 'Basic %s' % base64.b64encode('%s:%s' % (uname, pword))}
if provider=='bandwidth':
data = json.dumps({'from': '+%s' % src, 'to': '+%s' % dst, 'text': txt})
logger.debug(settings.bandwidth_send % uid)
url = settings.bandwidth_send % uid
headers = {'Content-Type': 'application/json',
'Authorization': 'Basic %s' % base64.b64encode('%s:%s' % (uname, pword))}
if provider=='nexmo':
url = settings.nexmo_send % (uid, uname, src, dst, txt)
return r