1

I found an interesting solution here to get the instagram public profile photos.

var name = "smena8m",
  items;
$.getJSON("https://query.yahooapis.com/v1/public/yql?callback=?", {
  q: "select * from json where url='https://www.instagram.com/" + name + "/?__a=1'",
  format: "json"
}, function(data) {
  console.log(data);
  if (data.query.results) {
    items = data.query.results.json.user.media.nodes;
    $.each(items, function(n, item) {
      $('body').append(
        $('<a/>', {
          href: 'https://www.instagram.com/p/'+item.code,
          target: '_blank'
        }).css({
          backgroundImage: 'url(' + item.thumbnail_src + ')'
        }));
    });
  }

});

i am trying to do the same in my nodejs app:

var request = require('request');
var name = "smena8m";
var propertiesObject = { q: "select * from json where url='https://www.instagram.com/" + name + "/?__a=1'" };
var myurl = "https://query.yahooapis.com/v1/public/yql?callback=?";
var items;
request.get(myurl, { qs:propertiesObject}, function(err, response, body) {
  if(err) { console.log(err); return; }
  console.log("Get response: " + response.statusCode);

    if (body.data.query.results) {
    items = body.data.query.results.json.user.media.nodes;
    items.forEach(function(n, item) {

        var itemCodes = 'https://www.instagram.com/p/'+item.code;
        var thumbnails =  item.thumbnail_src;
        console.log('here: ', itemCodes, thumbnails);

    });
  }
});

but my body returns empty. could somebody help me achieve the same in nodejs?

update:

response code is 200 and body is empty.

moaningalways
  • 461
  • 1
  • 10
  • 21

1 Answers1

-2

change myurl to:

 myurl='https://www.instagram.com/' +name '/?__a=1';

console.log(body) then and you should be happy!

Waelsy123
  • 594
  • 2
  • 13