Answer the question
In order to leave comments, you need to log in
How to parse photos from the VKontakte wall and write all the information to the database?
Until I got to this one
<?php
$wall = file_get_contents("http://api.vk.com/method/wall.get?v=5.3&filter=others&domain=id105297973&count=3");
$wall = json_decode($wall);
$wall = $wall->response->items;
for ($i = 0; $i < count($wall); $i++) {
echo "<p><b>".($i + 1)."</b>. <i>".$wall[$i]->text."</i>".date("Y-m-d H:i:s", $wall[$i]->date)."</span></p>";
}
?>
Answer the question
In order to leave comments, you need to log in
I didn’t quite understand what kind of information needs to be written to the database, but the essence, I think, will be clear.
<?php
function aprint($a)
{
print "<pre>";
print_r($a);
print "</pre>";
}
$wall = file_get_contents("http://api.vk.com/method/wall.get?v=5.3&filter=others&domain=id105297973&count=10");
$wall = json_decode($wall);
$wall = $wall->response->items;
$data = [];
foreach($wall as $w)
{
if (isset($w->attachments))
{
foreach ($w->attachments as $attach)
{
if ($attach->type === "photo")
{
$data[] = $attach->photo;
//здесь можно и записывать что-то в бд
}
}
}
}
aprint($data);
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question