-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
152 lines (130 loc) · 7.98 KB
/
index.php
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<html lang="en">
<head>
<title>Call You Ishmael</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Being Bootstrap Stylesheet -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<!-- End Bootstrap stylesheet -->
<link rel="stylesheet" href="style.css">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-100757086-1', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<div class="container">
<div class="row justify-content-md-center">
<div class="jumbotron">
<img src="whale.png" class="img-fluid whale"/>
<h1>Call You Ishmael</h1>
<!-- start form -->
<form action="#" method="post" class="form-inline">
<div class="form-group">
<input type="text" id="PhoneNumber" name="PhoneNumber" placeholder="Phone Number" class="form-control mb-2 mr-sm-2 mb-sm-0 col-form-label-lg"/>
<input type="submit" value="Call" class="btn btn-primary btn-lg"></div>
</form>
<!-- end form -->
<?php
// Step 1: Get the Twilio-PHP library from twilio.com/docs/libraries/php,
// following the instructions to install it with Composer.
require __DIR__ . "/twilio-php-master/Twilio/autoload.php";
use Twilio\Rest\Client;
// Step 2: Set our AccountSid and AuthToken from https://twilio.com/console. This is now included via config.php
require 'config.php';
// Step 3: Instantiate a new Twilio Rest Client
$client = new Client($AccountSid, $AuthToken);
// get the phone number from the page request parameters, if given
if (isset($_REQUEST['PhoneNumber'])) {
$number = htmlspecialchars($_REQUEST['PhoneNumber']);
// wrap the phone number or client name in the appropriate TwiML verb
// by checking if the number given has only digits and format symbols
if ((preg_match("/^[\d\+\-\(\) ]+$/", $number)) && (strlen($number) > 9)){
// Initiate a new outbound call
$call = $client->
account->calls->create(
// Step 4: Change the 'To' number below to whatever number you'd like
// to call.
$number,
// Step 5: Change the 'From' number below to be a valid Twilio number
// that you've purchased or verified with Twilio. Set in config.php.
$FromNumber,
// Step 6: Set the URL Twilio will request when the call is answered. Set in config.php.
array("url" => $CallURL, "timeout" => "10")
);
echo "
<div class='alert alert-success' role='alert'> <strong>Started call with</strong>
" . $number . "
</div>
";
} else {
echo "
<div class='alert alert-danger' role='alert'> <strong>Invalid Number</strong>
</div>
";
}
}
?>
<div class="row buttons">
<div class="col-lg-12">
<button type="button" class="btn btn-outline-secondary btn-sm" data-toggle="modal" data-target="#whatisthis">What is this?</button>
<button type="button" class="btn btn-outline-secondary btn-sm" data-toggle="modal" data-target="#disclaimer">Disclaimer</button>
</div>
</div>
</div>
</div>
<!-- start what is this modal -->
<div class="modal fade" id="whatisthis" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">What is this?</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Call You Ishamel is a service that brings Moby Dick directly to your phone! Through the power of text to speech technology, you can now experience Melville's classic novel no matter your location! Just enter your phone number and Call You Ishmael will call <strong>you</strong>!</p>
<p>I set this up as an excuse to get familiar with the <a href="https://www.twilio.com">Twilio</a> API. Feel free to contribute or fork this project <a href="https://github.com/cjreinhardt/callyouishmael.com/">at GitHub</a>!</p>
<small class="copyright"><a href="https://www.creinhardt.com">A dumb project by Chris Reinhardt</a></small>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- end what is this moda; -->
<!-- start disclaimer modal -->
<div class="modal fade" id="disclaimer" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Disclaimer</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>We will not sell your phone number, or use it for any purpose other than forcing a computer to read you Moby Dick.</p><p>Please use this for good, not evil.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- end disclaimer moda; -->
</div>
<!-- Begin bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
<!-- End Bootstrap JS -->
</body>
</html>