-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.php
40 lines (33 loc) · 896 Bytes
/
index.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
<?php
$registrationIds = array( $_POST['id'] );
$title = $_POST['title'] ;
$subtitle = $_POST['subtitle'] ;
$data = $_POST['data'] ;
// prep the bundle
$msg = array
(
'title' => $title,
'subtitle' => $subtitle,
'data' => $data
);
$fields = array
(
'registration_ids' => $registrationIds,
'data' => $msg
);
$headers = array
(
'Authorization: key = put...your..api_key..here...Find...out...it..from...google-services.json file ',
'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 ) );
$result = curl_exec($ch );
curl_close( $ch );
echo $result;
?>