N
N
n_shtain2014-11-29 00:29:22
PHP
n_shtain, 2014-11-29 00:29:22

Wall.get php VK API, how to get username and photo?

There is a code that displays photos that users have attached to posts:

<?php
$wall = file_get_contents("http://api.vk.com/method/wall.get?extended=1&owner_id=-21894049&v=5.21&filter=all&count=30"); // Отправляем запрос
$wall = json_decode($wall); // Преобразуем JSON-строку в массив
$wall = $wall->response->items; // Получаем массив
for ($i = 0; $i < count($wall); $i++) {
$x = $wall[$i]->text;
if($x !== ''){ // Не выводим пустые посты.
echo "".$wall[$i]->text."</br>"; // Выводим текст поста
$a = $wall[$i]->attachments[0]->photo->photo_604;
echo "<img src= '$a'>"; 
}}
?>

Please tell me how to display a photo and username for each post.
To display photos, I change attachments to profiles, and then I'm at a dead end. Using the poke method, I do the following:
$a = $wall[$i]->profiles[0]->id->photo_50;
  echo "<img src= '$a'>";

Does not work.
Please tell
me 1) how to "finish off" the output of the photo?
2)how to display the username?
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Wolf, 2014-11-29
@mannaro

Light up the VK API

W
WebEditor, 2014-11-29
@WebEditor

read about users.get

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question