-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.php
94 lines (84 loc) · 3.35 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
<?php
if (isset($_POST["send"])) {
$to = $_POST["to"];
$from = $_POST["from"];
$message = $_POST["message"];
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, 'API_KEY:API_PASSWORD');
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_URL, sprintf('https://api.twilio.com/2010-04-01/Accounts/API_KEY/Messages.json', 'API_KEY'));
curl_setopt($ch, CURLOPT_POST, 3);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'To='.$to.'&From='.$from.'&Body='.$message);
//execute post
$result = curl_exec($ch);
$result = json_decode($result);
//close connection
curl_close($ch);
if($result) {
$success = "Message sents";
}else{
$error = "Sent failed";
}
}
//This script has been developed with love by ADELEYE AYODEJI => adeleyeayodeji.com
//Having issues, am always ready to help.
?>
<!DOCTYPE html>
<html>
<head>
<title>Send message to your phone</title>
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="container">
<div class="header" style="padding: 20px;">
<h2 style="text-align: center;">A Simple PHP SMS API</h2>
</div>
<div class="main">
<form method="post" action="">
<div class="form-group">
<label>
From: <code>[Your Valid Purchased Number]</code>
</label>
<input type="text" name="from" class="form-control" required="">
</div>
<div class="form-group">
<label>To: <code>[Any International Number]</code></label>
<input type="text" name="to" class="form-control" required="">
</div>
<div class="form-group">
<label>Message</label>
<textarea class="form-control" required="" name="message"></textarea>
</div>
<div class="form-group">
<input type="submit" name="send" value="Send Message" class="btn btn-large btn-primary">
</div>
<?php
if (isset($success)) {
?>
<div class="alert alert-success" role="alert">
Message sents to <?php echo $to; ?>
</div>
<?php
}
if (isset($error)) {
?>
<div class="alert alert-danger" role="alert">
Failed to send message to <?php echo $to; ?>
</div>
<?php
}
?>
</form>
<div class="footer">
<a href="http://adeleyeayodeji.com/" target="_blank">Having Problem with the sourcecode, Contact the developer</a>
</div>
</div>
</div>
</body>
</html>