-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequest.php
More file actions
29 lines (27 loc) · 989 Bytes
/
request.php
File metadata and controls
29 lines (27 loc) · 989 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
<?php
require_once('db_constants.php');
function doRequest() {
$bdd = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=utf8', DB_USERNAME, DB_PASSWORD);
$request = $bdd->query('SELECT * FROM '.TABLE_GENERAL.' WHERE name = "emergency" ');
if ($request->rowCount() == 1) {
$row = $request->fetch();
} else {
$row= array('value' => 'NORMAL');
}
if ($row['value'] == 'NORMAL') {
$curl = curl_init("https://fcm.googleapis.com/fcm/send");
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
$var = array(
'to' => '/topics/condor541951236',
'data' => array('what' => 'sync')
);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json', 'Authorization:key=***REMOVED***'));
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($var));
$answer = curl_exec($curl);
curl_close($curl);
}
}
?>