Попробуйте так:
<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
$data = [
"host" => "www.example.com",
"key" => "EdD8dkmdNLlxREi2LkhJjYOH2kyQbJqM3cBKT5fX",
"keyLocation" => "https://www.example.com/myIndexNowKey63638.html",
"urlList" => [
"https://www.example.com/url1",
"https://www.example.com/folder/url2",
"https://www.example.com/url3"
]
];
$data_string = json_encode($data);
$result = file_get_contents('https://yandex.com/indexnow', null, stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => array(
"Content-Type: application/json; charset=utf-8\r\n" .
"Content-Length: " . strlen($data_string) . "\r\n" .
"Host: yandex.com"
),
'content' => $data_string
)
)
)
);
header('Content-Type: application/json; charset=UTF-8');
echo $result;