Есть работающий запрос вида:
curl -X POST --header "Authorization: key=bla-bla-bla" --Header "Content-Type: application/json" https://fcm.googleapis.com/fcm/send -d "{\"to\":\"bla-bla-bla2\",\"notification\":{\"body\":\"Yellow\"},\"priority\":10}
Что я делаю не так, записав его на php
<?php
$context = stream_context_create(array(
'http' => array(
'method'=>"POST",
'content' => $reqdata = http_build_query(array(
'to' => 'bla',
'notification' => "{\"body\":\"Yellow\"}",
'priority' => 10,
)),
'header' => implode("\r\n", array(
"Content-Length: " . strlen($reqdata),
"Authorization: key=bla2",
"Content-Type: application/json",
""
)),
)));
if (false !== $response = @file_get_contents("https://fcm.googleapis.com/fcm/send", false, $context)) {
$res = json_decode($response,true);
print_r($res)
}
strlen($reqdata)
возвращает размер контента в байтах, а не длину строки контента в символах?