-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsenNoty.php
61 lines (44 loc) · 1.77 KB
/
senNoty.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?PHP
function sendMessage(){
$content = array(
"en" => 'English Message',
"title"=>"Bibel Live Church",
"message"=>"Live on youTube"
);
/*$fields = array(
'app_id' => "2d5fd8a9-4340-481e-9431-27b7cea1e773",
'include_player_ids' => array("15331ccd-2ca8-45f1-aef3-0bb1eef91683"),
'data' => array("foo" => "bar"),
'contents' => $content
);*/
$fields = array(
'app_id' => "2d5fd8a9-4340-481e-9431-27b7cea1e773",
'included_segments' => array('All'),
'data' => array("foo" => "bar"),
'large_icon' =>"ic_launcher_round.png",
'contents' => $content
);
$fields = json_encode($fields);
print("\nJSON sent:\n");
print($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8','Authorization: Basic NzgxMjVlZmMtMGYyZi00MTg3LWEzOGUtOWMyZWVkODdmODJi'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
if($_GET["dowork"]=="senNoty"){
$response = sendMessage();
$return["allresponses"] = $response;
$return = json_encode( $return);
print("\n\nJSON received:\n");
print($return);
print("\n");
}
?>