J
J
jackie chan2015-11-06 17:49:53
PHP
jackie chan, 2015-11-06 17:49:53

Executing a php script every few seconds how?

there is such a code

$statusg = json_decode(file_get_contents('https://api.vk.com/method/status.get'. '?' .urldecode(http_build_query($statusget))), true);
    $status_data = ($statusg['response']['text']);

I display the result
<div class="data_status">Сечас играет: <?php echo "$status_data"; ?></div>

The question is how to make a request every 10 seconds?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Max, 2015-11-06
@MaxDukov

ajax?

V
VisualIdeas, 2015-11-06
@VisualIdeas

There are 2 obvious options:
1) Pull through the setInterval JavaScript function in which PHP will be called from the server, which will learn the data about the song from the VK API and display it, and the javascript that receives this data will display it on the page.
2) Direct access to VK API via JAvascript

G
Godmode, 2015-11-06
@god_mode_admin

Cron once per minute, inside this script sleep(10) will be 6 times per minute

R
Ruslan Sadikhov, 2015-11-06
@fsdsdfsfdsfsdfsdfsdfsdfsd

bash:

while true; do
 php -f script.php
 sleep 10
done

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question