N
N
nastyskafomka2019-04-28 11:11:47
PHP
nastyskafomka, 2019-04-28 11:11:47

How to specify dates when requesting VK group statistics?

Hello, I want to get statistics data, for example, from 04/21/2019 to 04/28/2019
I make the request as follows (I use the official library):

function show($data){
    print_r ("{$data}.<br>");
}
$date = "2019-04-21";
$now = date ("Y-m-d",time ());
echo strtotime ($date)."---".time ()."<br>";
$nd = $vk->stats ()->get($token,[
    "group_id"=>"000000000",
    "interval"=>"week",
    "timestamp_from" => strtotime ($date),
    "timestamp_to" => strtotime ($now),
    "stats_groups" => "visitors"

]);
print_r ("С ".date ("Y-m-d",$nd[0]["period_from"])."<br>");
print_r ("По ".date ("Y-m-d",$nd[0]["period_to"])."<br>");

show ("Всего просмотров за период: {$nd[0]["visitors"]['views']}");
show ("Всего посетителей за период: {$nd[0]["visitors"]['visitors']}");

print_r ($nd[0]);

As a result, I get:
5cc55e2b016ad987239124.png
If you remove the line "interval"=>"week" from the parameters, then you get the following:
5cc55ee320c2f772981931.png
Where 1555794000---1556438584 - date_from---date_now
What could be the problem? I honestly don't understand.
Who can faced it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question