0

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

3
  • А попробуйте внимательно поизучать страницу с документацией. Ну, так, совсем внимательно.
    – etki
    16 ноя 2014 в 22:05
  • Я слеп. Я попробовал пару вариантов, но мне это не особо помогло.
    – GALGANOVIN
    16 ноя 2014 в 22:12
  • @Etki, я уже пробовал данный вариант, но не вышло. Впервые работаю с API VK, да и вообще с API. Мне бы пример.
    – GALGANOVIN
    16 ноя 2014 в 22:26

2 ответа 2

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
  • @Etki, спасибо Вам ;) Хоть кто-то откликнулся.
    – GALGANOVIN
    16 ноя 2014 в 23:10
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'];

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.