File: //opt/plugins/atalantini/data/notification.php
<?php
require_once('../../../../wp-load.php');
global $wpdb;
function sendMessage($title, $link, $postId){
$content = array(
"en" => $title
);
$fields = array(
'app_id' => "10b06f3c-021f-446e-9878-7cd2547f4584",
'included_segments' => array('All'),
'url' => $link,
'data' => array("postId" => ""),
'headings' => array("en" => "Atalantini.com"),
'contents' => $content,
'large_icon' => 'https://www.atalantini.online/wp-content/themes/atalantini/images/logo_blu.png',
'small_icon' => 'https://www.atalantini.online/wp-content/themes/atalantini/images/logo_blu.png'
);
$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 ZTUyNDk2ZTAtNGM1OS00MzMzLTllOWUtYjBiYTMxZDJiOTg5'));
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;
}
echo sendMessage($_POST['notifica'], $_POST['link'], "");
?>
{"result":"ok"}