forked from sinch/php-sms-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsms.php
More file actions
26 lines (21 loc) · 683 Bytes
/
sms.php
File metadata and controls
26 lines (21 loc) · 683 Bytes
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
<?php
$key = "your_app_key";
$secret = "your_app_secret";
$user = "application\\" . $key . ":" . $secret;
$message = array("message"=>"Test");
$data = json_encode($message);
$ch = curl_init('https://messagingapi.sinch.com/v1/sms/+16507141052');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD,$user);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($ch);
if(curl_errno($ch)) {
echo 'Curl error: ' . curl_error($ch);
} else {
echo $result;
}
curl_close($ch);
?>