<?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;
$( document ).ready(function() {
//удаляем тильдовскую отправку формы
$( "#form371121162 button[type='submit']" ).attr('id', 'submit-btn');
$( "#form371121162 button[type='submit']" ).removeAttr('type');
//добавляем ajax по клику на кнопку
$( "#form371121162 #submit-btn" ).click(function(e) {
console.dir(e);
var msg = new FormData($("#form371121162")[0]);
$.ajax({
data: msg,
method: "POST",
url: '/api.php',
});
});
});
<menu id="html5menu" style="display:none" class="showcase">
<command label="Start" icon="fa-play" onclick="$.ajax('/start.php');">
<command label="Stop" icon="fa-stop" onclick="$.ajax('/stop.php');">
<command label="Delete" icon="fa-trash-alt" onclick="$.ajax('/delete.php');">
</menu>
<?php
header('Content-Type: text/plain; charset=UTF-8');
$data = file_get_contents('https://site.com/json_config/count.json');
if ($data !== false) {
$arr = json_decode($data, true);
echo "Из конфига получены следующие данные:\n";
echo print_r($arr, true);
}
else {
echo "Не удалось прочитать файл конфигурации!";
}
?>