I'm attempting to access a user's public profile page's JSON to pull information from it, but I keep getting redirected to the login page. I was using this link which works only when logged in. https://www.instagram.com/{username}/?__a=1
Is there a way for me to grab this information without logging in? I'm using PHP right now. I want to change the static JSON file to hopefully the live Instagram link to get live updates.
<?php
//This is hotpush.php
$string = file_get_contents("test.json");
$json_a = json_decode($string, true);
//var_dump(json_decode($string, true));
echo $json_a["graphql"]["user"]["edge_followed_by"]["count"];
?>
I have the file echoing to a webpage like so:
<!DOCTYPE html>
<html>
<body>
<div class = "testing">
<form action="hotpush.php" method = "post">
<input type = "text" id = "businesst" name = "businessta"><br>
<input type="submit" value="Submit">
<div class="msg"></div>
</form>
</div>
<script>
document.querySelector(".testing form").onsubmit = function(event) {
event.preventDefault();
var form_data = new FormData(document.querySelector(".testing form"));
var xhr = new XMLHttpRequest();
xhr.open("POST", document.querySelector(".testing form").action, true);
xhr.onload = function () {
if (this.responseText.toLowerCase().indexOf("success12312414sadadasf1") !== -1) {
window.location.href = "thankyou.html";
} else {
document.querySelector(".msg").innerHTML = this.responseText;
}
};
xhr.send(form_data);
};
</script>
</body>
</html>