V
V
Viktor Yanyshev2017-05-13 19:59:14
PHP
Viktor Yanyshev, 2017-05-13 19:59:14

Why does VK receive the wrong number of shares when asking for the number of shares?

On LP, social media is used to vote for each video. The problem is that the number of shares made through VK periodically jumps. In the morning it shows that the video has 89 votes made through VK, and after a couple of hours it becomes 1 or some other number.
I find out the number of shers like this:

$url = 'http://example.com/456239060';
        preg_match('/[\d]+/',$url, $idx);
          $data = file_get_contents('https://vk.com/share.php?act=count&index='.$idx[0].'&url='.$url);
         if(preg_match('/VK\.Share\.count\([0-9]+, ([0-9]+)\)\;/is', $data, $match)) {
              $data = intval($match[1]);
              return $data;
          } else {
              return false;
          }

The request for the number of shares occurs each time the page is loaded.

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