Skip to content

Instantly share code, notes, and snippets.

@nfriedly
Created January 10, 2012 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfriedly/1591588 to your computer and use it in GitHub Desktop.
Save nfriedly/1591588 to your computer and use it in GitHub Desktop.
FB long graph query fix
FB.ApiServer.flash = function(b, e, c, d, a){
if (!window.FB_OnXdHttpResult) window.FB_OnXdHttpResult = function(g, f) {
FB.ApiServer._callbacks[g](decodeURIComponent(f));
};
FB.Flash.onReady(function() {
if (b === 'graph') d.suppress_http_code = 1;
var h = FB.getDomain(b) + e,
f = FB.QS.encode(d);
if (c === 'get') {
if (h.length + f.length > 2000) {
if (b === 'graph') d.method = 'get';
c = 'post';
f = FB.QS.encode(d);
// new code here to move GET params from the url to the POST body
if(h.indexOf('?') >= -1){
f = h.substr(h.indexOf('?')+1) + '&' + f;
h = h.substr(0, h.indexOf('?'));
}
} else {
h += (h.indexOf('?') > -1 ? '&' : '?') + f;
f = '';
}
} else if (c !== 'post') {
if (b === 'graph') d.method = c;
c = 'post';
f = FB.QS.encode(d);
}
var g = document.XdComm.sendXdHttpRequest(c.toUpperCase(), h, f, null);
FB.ApiServer._callbacks[g] = function(i) {
a && a(FB.JSON.parse(i));
delete FB.ApiServer._callbacks[g];
};
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment