Cree una aplicación de notificaciones con la API de OneSignal, y hace un momento todo me funcionaba excelente. Pero derrepente me arroja este error:
{
"response": {
"status": 400,
"error": "There was a problem in the JSON you submitted: unexpected characters after the JSON document at line 1, column 1 [parse.c:590]"
}
}
Este es mi código php:
<?php
header('Content-Type: application/json');
function sendMessage(){
$content = array(
"en" => 'Hi'
);
$fields = [
'app_id' => "xxxxxx-xxxx-xxxx-xxx-xxxxxxx",
'include_player_ids' => [
"xxxxxx-xxxx-xxx-xxxxxxx-xxxx"
],
'contents' => $content
];
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => "https://onesignal.com/api/v1/notifications",
CURLOPT_HTTPHEADER => array('Content-Type: application/json; charset=utf-8', 'Authorization: Basic xxxxxxxxxxxxxxxxxxxxx'),
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HEADER => FALSE,
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => $fields,
CURLOPT_SSL_VERIFYPEER => FALSE
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response);
}
$response = sendMessage();
$return["response"] = $response;
$return = json_encode($return, JSON_PRETTY_PRINT);
echo $return;
?>
El manifest.json
:
{
"name": "Page Name",
"short_name": "Short Page Name",
"start_url": "/",
"display": "standalone",
"gcm_sender_id": "xxxxxxx"
}
Aquí les dejo la documentación de la API de OneSignal.
manifest.json