/
fake-sms.html
138 lines (133 loc) · 5.85 KB
/
fake-sms.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
{% extends "../templates/base.html" %}
{#
Parameter Description
CallSid A unique identifier for this call, generated by Twilio.
AccountSid Your Twilio account id. It is 34 characters long, and always starts with the letters AC.
From The phone number of the party that initiated the call. Formatted with a '+' and country code e.g., +16175551212 (E.164 format). If the call is inbound, then it is the caller's caller ID. If the call is outbound, i.e., initiated via a request to the REST API, then this is the phone number you specify as the caller ID.
To The phone number of the called party. Formatted with a '+' and country code e.g., +16175551212 (E.164 format). If the call is inbound, then it's your Twilio phone number. If the call is outbound, then it's the phone number you provided to call.
CallStatus A descriptive status for the call. The value is one of queued, ringing, in-progress, completed, busy, failed or no-answer. See the CallStatus section below for more details.
ApiVersion The version of the Twilio API used to handle this call. For incoming calls, this is determined by the API version set on the called number. For outgoing calls, this is the API version used by the outgoing call's REST API request.
Direction Indicates the direction of the call. In most cases this will be inbound, but if you are using <Dial> it will be outbound-dial.
ForwardedFrom This parameter is set only when Twilio receives a forwarded call, but its value depends on the caller's carrier including information when forwarding. Not all carriers support passing this information.
#}
{% block 'content' %}
<h1 id="account_information">Fake an Inbound SMS</h1>
<div id="content">
<h2>Phone Number - {{data.PhoneNumber.PhoneNumber}}</h2>
{% if data.PhoneNumber.SmsUrl %}
{% if data.TwilioCode %}
<p class="error">
An error has occurred.<br>
{{data.TwilioCode}}<br>
{{data.TwilioMsg}}
</p>
{% endif %}
<p id="Additional" class="error hide">
In order to submit Additional Parameters, all of them must be valid.
</p>
<p id="Phone" class="error hide">
You have entered an invalid phone number.
</p>
<p id="Textarea" class="error hide">
You need to enter a message to send.
</p>
Sms Url: {{data.PhoneNumber.SmsUrl}} - Method: {{data.PhoneNumber.SmsFallbackMethod }} <br>
Sms Fallback Url: {{data.PhoneNumber.SmsFallbackUrl}} - Method: {{data.PhoneNumber.SmsFallbackMethod }}
<form action="/phone-numbers/sms/{{data.PhoneNumber.Sid}}" method="POST" accept-charset="utf-8">
<p>
<label for="From">From</label><input id="phone_number" name="From" value="{% if data.Arguments.From %}{{data.Arguments.From}}{% else %}+1{% endif %}">
</p>
<p>
<label for="To">To</label> <input type="hidden" name="To" value="{{data.PhoneNumber.PhoneNumber}}" id="To">{{data.PhoneNumber.PhoneNumber}}
</p>
<p>
<label for="Body">Body</label> <textarea name="Body">{% if data.Arguments.Body %}{{data.Arguments.Body}}{% endif %}</textarea>
</p>
<p>
<label for="ApiVersion">ApiVersion</label> 2010-04-01
</p>
<h3>Additional Parameters</h3>
<p>
<label for="FromCity">From City</label><input class="Additional" name="FromCity" value="{% if data.Arguments.FromCity %}{{data.Arguments.FromCity}}{% endif %}">
</p>
<p>
<label for="FromState">From State</label><input class="Additional" name="FromState" value="{% if data.Arguments.FromState %}{{data.Arguments.FromState}}{% endif %}">
</p>
<p>
<label for="FromZip">From Zip</label><input class="Additional" name="FromZip" value="{% if data.Arguments.FromZip %}{{data.Arguments.FromZip}}{% endif %}">
</p>
<p>
<label for="FromCountry">From Country</label><input class="Additional" name="FromCountry" value="{% if data.Arguments.FromCountry %}{{data.Arguments.FromCountry}}{% endif %}">
</p>
<p>
<label for="ToCity">To City</label><input class="Additional" name="ToCity" value="{% if data.Arguments.ToCity %}{{data.Arguments.ToCity}}{% endif %}">
</p>
<p>
<label for="ToState">To State</label><input class="Additional" name="ToState" value="{% if data.Arguments.ToState %}{{data.Arguments.ToState}}{% endif %}">
</p>
<p>
<label for="ToZip">To Zip</label><input class="Additional" name="ToZip" value="{% if data.Arguments.ToZip %}{{data.Arguments.ToZip}}{% endif %}">
</p>
<p>
<label for="ToCountry">To Country</label><input class="Additional" name="ToCountry" value="{% if data.Arguments.ToCountry %}{{data.Arguments.ToCountry}}{% endif %}">
</p>
<p>
<input type="submit" value="Send SMS">
</p>
</form>
{% else %}
You must set a SMS Url before inbound calls can be received.
{% endif %}
</div>
<script type="text/javascript" charset="utf-8">
//phone_number jquery objec
function validate_phone_number(phone_number) {
pn = phone_number.val().replace(/[^0-9]/g, '');
if(pn.length == 11){
phone_number.val('+'+pn);
return true;
}else{
if(pn.length == 10){
phone_number.val('+1'+pn);
return true;
}else{
phone_number.val('+'+pn);
return false;
}
}
}
//THIS IS SOME REALLY BAD JS, but it's just for some upfront nice-ity
$(document).ready(function() {
$('form').submit(function() {
$('#Additional').slideUp();
$('#Phone').slideUp();
$('#Textarea').slideUp();
valid = true;
any = false;
$('.Additional').each(function(index) {
if($(this).val() == ''){
valid = false;
}else{
any = true;
}
});
if(any && !valid){
$('#Additional').slideDown();
return false;
}else{
if (validate_phone_number($('#phone_number'))){
if ($('textarea[name="Body"]').val() == '') {
$('#Textarea').slideDown();
return false;
}else{
return true;
}
}else{
$('#Phone').slideDown();
return false;
}
}
});
});
</script>
{% endblock %}