-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_notification.php
More file actions
30 lines (27 loc) · 826 Bytes
/
send_notification.php
File metadata and controls
30 lines (27 loc) · 826 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
27
28
29
30
<?php
function sendNotification(){
$url ="https://fcm.googleapis.com/fcm/send";
$fields=array(
"to"=>$_REQUEST['token'],
"notification"=>array(
"body"=>$_REQUEST['message'],
"title"=>$_REQUEST['title'],
"icon"=>$_REQUEST['icon'],
"click_action"=>"https://google.com"
)
);
$headers=array(
'Authorization: key=YOUR_SERVER_KEY',
'Content-Type:application/json'
);
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,json_encode($fields));
$result=curl_exec($ch);
print_r($result);
curl_close($ch);
}
sendNotification();