-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex5.php
More file actions
49 lines (34 loc) · 1.26 KB
/
index5.php
File metadata and controls
49 lines (34 loc) · 1.26 KB
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
<?php
require __DIR__ . '/vendor/autoload.php';
if(isset($_POST['mobile']) && isset($_POST['msg'])){
// Your Account SID and Auth Token from twilio.com/console
$account_sid = 'YOUR-TWILIO-SID-HERE';
$auth_token = 'YOUR-AUTH-TOKEN-HERE';
// In production, these should be environment variables. E.g.:
// $auth_token = $_ENV["TWILIO_AUTH_TOKEN"]
// A Twilio number you own with SMS capabilities
$twilio_number = "YOUR-TWILIO-NUMBER-HERE";
$client = new Twilio\Rest\Client($account_sid, $auth_token);
$message = $client->messages->create(
// Where to send a text message (your cell phone?)
$_POST['mobile'],
array(
'from' => $twilio_number,
'body' => $_POST['msg']
)
);
if($message){
echo "Message sent succesfully!";
}else{
echo 'Error! Message not sent!';
}
}
?>
<h2>Sending SMS using twilio API<h2>
<form method= "post" action="#">
Enter Mobile Number:<br><br>
<input type="text" placeholder = "Mobile Number" name ="mobile"><br><br>
Enter Message:<br><br>
<textarea placeholder= "Message" name= "msg"></textarea><br><br>
<input type="submit" value="Submit">
<form>