Guest User

Untitled

a guest
Jul 29th, 2016
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. $json_string = file_get_contents('http://api.vk.com/method/wall.get?v=5.7&domain=verstka_html');
  2. $json = json_decode($json_string, true);
  3. $all_posts = $json['response'];
  4. $photoUrl = array();
  5. foreach ($all_posts['items'] as $post) {
  6. if (!empty($post['attachments'])) {
  7. foreach ($post['attachments'] as $postAttachment) {
  8. if ($postAttachment['type'] == 'photo') {
  9. $photoUrl[] = $postAttachment['photo'];
  10. }
  11. }
  12. }
  13. }
  14.  
  15. foreach ($photoUrl as $item) {
  16. if (!empty($item['photo_807'])) {
  17. return $item['photo_807'];
  18. }
  19. }
  20. return '';
Advertisement
Add Comment
Please, Sign In to add comment