A
A
Artur Yalaltdinov2016-03-19 04:54:41
JavaScript
Artur Yalaltdinov, 2016-03-19 04:54:41

VK OpenAPI wall.get js?

Good night, I ran into a problem I can’t solve
The problem is to load images from VK using the wall.get method
Do it like this

VK.Api.call('wall.get', {domain: 'mirfactov', count: 15, offset: 1}, function(r) {

        console.log(r.response);
        for(var i = 1; i < count(r.response); i++)
        {
          if(r.response[i].attachment)
          {
            switch(r.response[i].attachment.type)
            {
              case "photo": {
                
                for(var n = 0; n < count(r.response[i].attachments); n++)
                {
                  console.log(r.response[i].attachments[n].photo.src + " number: " + n);
                }
                break;
              }
            }
          }
        }
      });

It displays to me all the n-th number of images of the 1st post and 1 image of the 2nd post, but after some reason he does not want to download, although there are images after. Console says
TypeError: r.response[i].attachments[n].photo is undefined

Solved a problem
if(r.response[i].attachments[n].type == "photo")
                  {
                    console.log(r.response[i].attachments[n].photo.src + " number: " + n);
                  }

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