-
Notifications
You must be signed in to change notification settings - Fork 2
/
smsandnotification.php
72 lines (62 loc) · 2.69 KB
/
smsandnotification.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
<?php
function send_notifications($message,$title,$notification_ids) {
$API_ACCESS_KEY = 'FCM Key'; //For Example AAAA-asCEBI:APA91bHQuS4aB0B4AKYF3q7jDV69zR8iQIXyNBmnLNycvXdVRt9EsF-rvQkt5ZAivnm9qDf712Okmb76A8zKdc_GY8_WVYVeIyt0oI7TLqS_OeMDFZLJUsDe_go7zjftjOpdoLJbfbRJSGQ
$data = array(
'title' => $title,
'message' => $message
);
// $fields = array('to' => '/topics/news', 'priority' => 'high', 'data' => $data );
$fields = array('to' => $notification_ids, 'priority' => 'high', 'data' => $data );
json_encode($fields);
$headers = array(
'Authorization: key=' . $API_ACCESS_KEY,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$pushResult = curl_exec($ch);
curl_close($ch);
}
function send_sms($message,$title,$numbers) {
// Authorisation details.
$username = "Your UserName";//User name http://api.textlocal.in
$hash = "Your Hash Key";// Hash key 20bd88f537025acab7eb4057263cc3ec7113
// Config variables. Consult http://api.textlocal.in/docs for more info.
$test = "0";
// Data for text message. This is the text message data.
$sender = "TXTLCL"; // This is who the message appears to be from.
//$sender = "TVMSCL";
// A single number or a comma-seperated list of numbers
$message = $title."\n".$message;
// 612 chars or less
// A single number or a comma-seperated list of numbers
$message = urlencode($message);
$data = "username=".$username."&hash=".$hash."&message=".$message."&sender=".$sender."&numbers=".$numbers."&test=".$test;
$ch = curl_init('http://api.textlocal.in/send/?');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo $result = curl_exec($ch); // This is the result from the API
curl_close($ch);
}
/*
function send_sms1($message,$title,$reciever_phone) {
//$url="http://".$_SERVER['HTTP_HOST']."/pushsms.php";
$url="https://smsleads.in/pushsms.php";
$sms=urlencode($title." ".$message);
$phones=$reciever_phone;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=wekex&password=Smsservice&sender=BEISMS&numbers=$phones&message=$sms");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
echo $response = curl_exec($ch);
}
*/
?>