Answer the question
In order to leave comments, you need to log in
How to work with api vk in php?
Help me deal with api vk likes.getlist
$request_params = array(
'type' => 'post',
'owner_id' => '-42621674',
'item_id' => '2146',
'filter' => 'likes',
'skip_own' => '0'
);
$get_params = http_build_query($request_params);
$result = json_decode(file_get_contents('https://api.vk.com/method/likes.getList?'. $get_params));
echo($result -> response[0] -> likes);
Answer the question
In order to leave comments, you need to log in
Your problem is not with the VK API, but with "echo($result -> response[0] -> likes);"
You are accessing an object like an array (see how the json_decode function works).
Decide how to work with $result.
1. Make it an array, then: (do print_r($result) and understand its structure)
$result = json_decode(file_get_contents('https://api.vk.com/method/likes.getList?'. $get_params), true);
echo $result["response"]["count"];
$result = json_decode(file_get_contents('https://api.vk.com/method/likes.getList?'. $get_params));
echo($result -> response -> count);
What about the correct IDs?
Just a test:
https://api.vk.com/method/likes.getList?type=post&...
This is this post:
https://new.vk.com/warm_music?w=wall-26797336_54325
Maybe your some closed one?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question