N
N
Niko2017-08-22 16:26:26
PHP
Niko, 2017-08-22 16:26:26

How to extract the information we need from the JSON (VK API) response?

Good afternoon. Using the VK API, namely the wall.get method, I get data about the community, where information about the proposed news is stored.
It comes to me as a JSON response:

{"response":{"count":3,"items":[{"id":8,"from_id":443375543,"owner_id":-148880857,"date":1503264466,"marked_as_ads":0,"post_type":"suggest","text":"фыафоывлдфыов","can_publish":1,"can_delete":1,"comments":{"count":0}}]}}

From all this JSON response, I need to extract information about "count" only.
Here is the code:
$request_params_for_suggests = [
'access_token' => $token['access_token'],
'domain' => $screen_name,
'count' => '1',
'filter' => 'suggests',
'v' => '5.68',
];
            
$url_for_suggests = "https://api.vk.com/method/wall.get?" . http_build_query($request_params_for_suggests);	
$result_suggests = file_get_contents($url_for_suggests);
$decode_suggests = json_decode($result_suggests);
foreach ($decode_suggests->response as $suggests_result)
$suggests = $result_suggests //Что тут надо прописать, чтобы получить информацию о "count" ? ;

Tried different ways, doesn't work. Help, who knows)
PS I use foreach so that it runs through all the communities and issues for each of them.

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