VK: wall.get method

Рейтинг: 0Ответов: 2Опубликовано: 17.11.2014

Как подсчитать, сколько всего записей на стене?

Ответы

▲ 2Принят

Rocket science

<?php

class VkApi
{
    protected $endpoint = 'https://api.vk.com/method/';
    protected $apiVersion = '5.26';
    public function getWallPostsAmount($id)
    {
        $data = $this->performRequest('wall.get', array('owner_id' => $id, 'count' => 1,));
        return $data['response']['count'];
    }
    protected function performRequest($method, $params)
    {
         $params['v'] = $this->apiVersion;
         $url = $this->endpoint . $method . '?' . http_build_query($params);
         return json_decode(file_get_contents($url), true);
    }

}

$api = new VkApi;
$id = 1;
var_dump($api->getWallPostsAmount($id));
▲ 1

Я сам уже. Как-то так вышло:

$json_string = file_get_contents('http://api.vk.com/method/wall.get?v=5.7&filter=all&domain=группа');
$json = json_decode($json_string, true);
$all_posts = $json['response']['count'];