0

I basically copy-pasted the MDN code, and I triple checked the URL. I can't find the reason as to why the responses differ. For reference, here is my code: Edit: Didn't see cookies got sent, I'm sorry

function getUsernames(str) {
  console.log(str)
} 
function reqListener() {
  alert(getUsernames(this.responseText));
}

var oReq = new XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "https://www.instagram.com/graphql/query/?query_hash=c76146de99bb02f6415203be841dd25a&variables=%7B%22id%22%3A%2217199917378%22%2C%22include_reel%22%3Atrue%2C%22fetch_mutual%22%3Atrue%2C%22first%22%3A24%7D");
oReq.responseType = "arraybuffer";
oReq.send();

oReq.onload = function(e) {
  var arraybuffer = oReq.response; // not responseText
  console.log(arraybuffer)
  /* ... */
}

2 Answers2

0

Seems the xmlhttprequest is truncated and does not contain the data you want unless you have key (auth)

Here is something hacky: How can I get a user's media from Instagram without authenticating as a user?

You also have two load handlers. You likely mean this

function getUsernames(str) {
  return JSON.parse(str); // of course do something with this when complete
} 
function reqListener() {
  console.log(getUsernames(this.responseText));
}

var oReq = new XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "https://www.instagram.com/graphql/query/?query_hash=c76146de99bb02f6415203be841dd25a&variables=%7B%22id%22%3A%2217199917378%22%2C%22include_reel%22%3Atrue%2C%22fetch_mutual%22%3Atrue%2C%22first%22%3A24%7D");
oReq.responseType = "text";
oReq.send();
mplungjan
  • 169,008
  • 28
  • 173
  • 236
-1

Okay, so I just found out that in the headers cookies got send. After clearing my cookies, I got the same result as the program. I thank you all for your participation!