Created
January 10, 2012 22:26
-
-
Save nfriedly/1591588 to your computer and use it in GitHub Desktop.
FB long graph query fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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