-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNiloRS.php
71 lines (60 loc) · 2.75 KB
/
NiloRS.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
62
63
64
65
66
67
68
69
70
71
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
$data = json_decode(file_get_contents('php://input'), true);
require('Notification.php');
$topic=$data["topic"];
$method = $data["method"];
$title = $data["title"];
$message = $data["message"];
$tokens = explode(",", $data["tokens"]);
$photoUrl = $data["image"];
$orderId = $data["id"];
$status = $data["status"];
//Código de pruebas hardcodeado
// $topic="topic_offers";
// $method = "sendNotificationByTopics";
// $title = "From Server";
// $message = "Custom Message:
//¿Qué es Lorem Ipsum?
//Lorem Ipsum es simplemente el texto de relleno de las imprentas y archivos de texto. Lorem Ipsum ha sido el texto de relleno estándar de las industrias desde el año 1500, cuando un impresor (N. del T. persona que se dedica a la imprenta) desconocido usó una galería de textos y los mezcló de tal manera que logró hacer un libro de textos especimen.";
// $tokens = explode(",", "[your token of device/delete brackets]");
$length = count($tokens);
/* for($i=0; $i< $length; $i++){
echo $tokens[$i];
echo "<br>";
echo "<br>";
}
*/
//***********************************************************************************************************
//***** AQUI INICIA LA DEFINICIÓN DE FUNCIONES QUE A SU VEZ ACCEDERAN A LOS MÉTODOS DEL OBJETO NOTIFICATION
//***********************************************************************************************************
function sendNotification($title, $message, $tokens, $orderId, $status){
$notification = new Notification();
$response=$notification->sendNotificationByTokens($title, $message, $tokens,$orderId, $status);
return $response;
}
function sendNotificationByTopics($title, $message, $topic, $image){
$notification = new Notification();
$response=$notification->sendNotificationByTopics($title, $message, $topic, $image);
return $response;
}
//************************************************************************************************************
//***** SWICH UTILIZADO PARA FILTRAR Y MANDAR A LLAMAR EL MÉTODO CORRESPONDIENTE
//************************************************************************************************************
switch ($method) {
case "sendNotification":{
$response=sendNotification($title, $message, $tokens, $orderId, $status);
break;
}
case "sendNotificationByTopics":{
$response=sendNotificationByTopics($title, $message, $topic, $photoUrl);
break;
}
default:{
$response["success"]=104;
$response["message"]='El método indicado no se encuentra registrado';
}
}
echo json_encode ($response)
?>