A
A
Alexey Sannikov2017-02-18 12:11:37
PHP
Alexey Sannikov, 2017-02-18 12:11:37

How to write a request to display an image (as a link) of the VK album cover (api)?

This task is to display the image (as a link) of the album cover from VK using the photos.getAlbums method . I was able to get the image using the thumb_src field, but I need a different size, for this I set the photo_sizes parameter to '1'. The question is how to get the reference from the sizes field , for example type P, where the size will be 200x150.
Here is my code:

<?php

$user_id = id_пользователя;

$request_params = array(
'owner_id' => $user_id,
'need_covers' => '1',
'photo_sizes' => '1'
);

$get_params = http_build_query($request_params);
$result = json_decode(file_get_contents('https://api.vk.com/method/photos.getAlbums?'. $get_params));

for ($i = 0; isset($result -> response[$i]); $i++)
  echo $result -> response[$i] -> sizes //Нужно здесь что-то изменить, но не понимаю как (опыт программирования небольшой)

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Zhilyaev, 2017-02-18
@kirill_782

1) Use foreach. Compare sizes.
2) use version 5 or later. 3 will soon stop being supported.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question