-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsms.php
More file actions
43 lines (28 loc) · 1.03 KB
/
sms.php
File metadata and controls
43 lines (28 loc) · 1.03 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
<?php
header('Content-Type = application/json');
$text = $_POST['text'];
$number = $_POST['number'];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$url = "https://rest.nexmo.com/sms/json";
$data = array(
'from' => 'Vonage APIs',
'text' => $text,
'to' => $number,
'api_key' => 'fd19536f',
'api_secret' => 'vqpEErCfFE2FpDK9'
);
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
if ($response === false) {
$error = curl_error($curl);
$result = array('success' => false, 'error' => $error);
} else {
$result = array('success' => true, 'response' => json_decode($response, true));
}
curl_close($curl);
echo json_encode($result);