jsanahuja / jquery.instagramFeed

Instagram Feed without access token. Not using the Instagram API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to load resource: the server responded with a status of 400 ()

georgiyboekov opened this issue · comments

Hello,

I've managed to get the Instagram Feed working, but at times, the console throws an error - *Failed to load resource: the server responded with a status of 400 ()

I have the following script written:

`(function($){
var defaults = {
'username': '',
'container': '',
'display_profile': true,
'display_biography': true,
'display_gallery': true,
'get_raw_json': false,
'callback': null,
'styling': true,
'items': 8,
'items_per_row': 4,
'margin': 0.5
};
$.instagramFeed = function(options){
options = $.fn.extend({}, defaults, options);
if(options.username == "" && options.tag == ""){
console.log("Instagram Feed: Error, no username or tag found.");
return;
}
if(!options.get_raw_json && options.container == ""){
console.log("Instagram Feed: Error, no container found.");
return;
}
if(options.get_raw_json && options.callback == null){
console.log("Instagram Feed: Error, no callback defined to get the raw json");
return;
}

var url = 'https://images' + ~~(Math.random() * 3333) + '-focus-opensocial.googleusercontent.com/gadgets/proxy?container=none&url=https://www.instagram.com/' + options.username;

$.ajax({
url: url,
type: 'GET',
success: function (data){
console.log(data.organizations[0].name);
var organisation = data.organizations[0].name;
$("#company").text(organisation);
}
});

$.get(url, function(data){
    console.log(data);
		data = data.split("window._sharedData = ");
		data = data[1].split("<\/script>");
		data = data[0];
		
		data = data.substr(0, data.length - 1);
		data = JSON.parse(data);`

The script is working and it's displaying the feed, but at times it stops and I have to retry for multiple times until it gets to work again. I've went through all threads and I believe there is no workaround on this case, but any tips at least to mitigate the problem are highly appreciated. I hope the discussion and the code is helpful to other users as well.

Kindest regards,
Georgiy

jQuery.ajax({
type: "GET",
url: "https://www.instagram.com/" + jQuery("#text_username").val() + "/?__a=1"

Have anyone tried to get the feed in this way? I can see it working on some website this way without issues and a proxy. I'm willing to pay a good amount to anyone that can make this working without a problem. Thanks!