-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush_note.php
More file actions
30 lines (30 loc) · 1.07 KB
/
push_note.php
File metadata and controls
30 lines (30 loc) · 1.07 KB
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
include('db.php');
$sql = $conn->query("SELECT * FROM `push_note` ORDER BY `id` DESC LIMIT 1");
$row = $sql->fetch_assoc();
$auth = $row['auth'];
define('API_ACCESS_KEY', 'AAAAK3NrYXM:APA91bF0okxIMbjeFmwYzFUX5iRTxzrB-WmVGOtBgSHnJeFJyvqYmnGAEQY5ldEONrimFd2z6JQDopPivAoDhZ0ykzbXpm3sGxlWUiVPYeCFYOgimgN6UAHktXIsn1RVZcmNpgp_lTD0');
$registrationids = array($auth);
$msg = array(
'massage' => 'here is a massage',
'title' => 'this is title. title',
'subtitle'=> 'subtitle',
'tickerText'=> 'ti8cker text',
'vibrate' => 1,
'sound' => 1 );
$fields = array(
'registration_ids' => $registrationids,
'data' => $msg );
$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,CURLTOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ));
$result = curl_exec( $ch );
echo $result;
?>