-
Notifications
You must be signed in to change notification settings - Fork 0
/
send_notification.php
38 lines (34 loc) · 1.25 KB
/
send_notification.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
<form method="post" action="send_notification.php">
Title<input type="text" name="title">
Message<input type="text" name="message">
<!--Icon path<input type="text" name="icon">-->
Token<input type="text" name="token">
<input type="submit" value="Send notification">
</form>
<?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://shinerweb.com"
)
);
$headers=array(
'Authorization: key=AAAAGjdsqvg:APA91bF46TjpRVDdEDxQb5imeK6dUB-vDh7iNtYEk93mNd0IOphEj7e35JlGEZMTXlcOpNXMHZ8FJyFxluzr0YiTghRv9w_Ptfpo0ni3pBFzyhZX0rdedT1MhjtWOAj2dhmoCCwFGYuB',
'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();