1
I’m deploying onesignal in my php system, following the Documentation
My code is:
function sendMessage(){
$content = array(
"pt" => $conteudo
);
$title = array(
"en" => $titulo
);
$fields = array(
'app_id' => "************************",
'included_segments' => array('All'),
'data' => array("foo" => "bar"),
'contents' => $content,
'headings' => $title,
'attachments' => array("url" => 'http://www.google.com')
);
$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 *******************************************************'));
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;
}
$response = sendMessage();
$return["allresponses"] = $response;
$return = json_encode( $return);
print("\n\nJSON received:\n");
print($return);
print("\n");
My problem is that the destination URL is not working, that is, so that when the user clicks on the notification it is redirected to this url.