def make_call(request): if request.is_ajax(): form = CallForm(request.POST) if form.is_valid(): callback = request.build_absolute_uri( reverse('phonetap-main-outgoing_inprogress') ) twilio = Twilio(settings.TWILIO_ACCOUNT_SID, \ settings.TWILIO_ACCOUNT_TOKEN) twilio_response = twilio.call(settings.TWILIO_SANDBOX_NUM, \ form.cleaned_data['caller_num'], callback) call = Call( call_sid=twilio_response.call_sid, caller_number=form.cleaned_data['caller_num'], callee_number=form.cleaned_data['callee_num'], caller_email=form.cleaned_data['caller_email'], current_status='Dialing' ) call.put() response = json.dumps({ 'success': True, 'call_page_url': request.build_absolute_uri( reverse('phonetap-main-view_call', args=[call.call_sid]) ) }) else: response = json.dumps({ 'success': False, 'errors': form.errors }) return HttpResponse(response, 'application/javascript') else: return HttpResponse(status=400)
from twiliosimple import Twilio # Account SID provided by Twilio account_sid = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' # Account Token provided by Twilio account_token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' # Number to appear on caller id. This number must be either provided by # Twilio or verifided through the web interface callout_num = '5555555555' # Number for Twilio to call num_to_call = '5555555555' # Callback URL for Twilio to use callback = 'http://example.org/callback.py' twilio = Twilio(account_sid, account_token) outgoing_call = twilio.call(callout_num, num_to_call, callback) # Prints Twilio's response to our call request print outgoing_call.get_response()
from twiliosimple import Twilio # Account SID provided by Twilio account_sid = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' # Account Token provided by Twilio account_token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' # Sender number. This must be a number that can send outgoing messages sender = '5555555555' # Number to send the message to to = '5555555555' # Body of the message body 'This is a text message coming from Twilio!' twilio = Twilio(account_sid, account_token) outgoing_sms = twilio.sms(sender, to, body) # Prints Twilio's response to our sms request print outgoing_sms.get_response()