File: /var/www/nclive/technc/send_push_notifications.php
<?php
include "config.php";
$type = $_REQUEST['type'];
$noti_id = $_REQUEST['noti_id'];
$array = array();
if($type == 'send')
{
if($noti_id !=""){
include 'push_notifications.php';
$queryRun = "SELECT n.title, e.exam_name, e.url_slug from sp_notification as n left join sp_exam as e on e.exam_id=n.exam_id where n.id='$noti_id'";
$run = $db->prepare($queryRun);
$run->execute();
$row = $run->fetch();
$title = $row['exam_name'];
$message = $row['title'].".... Click here to know";
$url = "http://naukriconnect.com/exam-details/".$row['url_slug'];
$app_url = "";
$response = sendMessage($title, $message, $url, $app_url);
$return["allresponses"] = $response;
$return = json_encode($return);
$data = json_decode($response, true);
$id = $data['id'];
if($id !=""){
$array = array('status'=>1, 'msg'=>"Push Notification Response ID is '".$id."'");
} else {
$array = array('status'=>0, 'msg'=>"Push Notification Response ID is blank");
}
} else {
$array = array('status'=>0, 'msg'=>"Push Notification ID is not Existed");
}
}
if($type == 'delete')
{
if($noti_id !=""){
$deleteQuery = "DELETE FROM sp_notification WHERE id='$noti_id'";
$delete = $db->prepare($deleteQuery);
if($delete->execute()){
$array = array('status'=>1, 'msg'=>"Header Notification is Successfully Deleted. ");
} else {
$array = array('status'=>0, 'msg'=>"Header Notification is not Deleted.");
}
} else {
$array = array('status'=>0, 'msg'=>"Delete ID is not Existed");
}
}
echo json_encode($array);
?>