I can’t seem to get the Facebook Graph API to work in IE7, IE8, and Opera while it is working fine in FF3.6, FF8, IE9, and Chrome.
I am following the Client-side Flow from the Facebook authentication docs.
I have a Facebook Connect link and when the user clicks on it the page is directed to:
https://www.facebook.com/dialog/client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&response_type=token
The user logs in and authorizes the app if needed.
The redirect_uri page gets the access_token back just fine. I then try to do an ajax get for https://graph.facebook.com/me to just return the public data (I need name and id).
The request does not succeed.
Doing some research and finding this stackoverflow post I tried changing the ajax response type to ‘text/javascript’ (also tried several others). Same issues occurs.
Removing ajax from the equation I try to hit the API directly with the browser (not logged into Facebook and without an access_token) like this example from Facebook Graph API Reference page.
I can view it fine in FF. I can download and then view it fine with IE9. I get this error in IE8:
Unable to download btaylor/ from graph.facebook.com.
Unable to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.
While searching for answers I found this stackoverflow post, and sure enough Facebook’s Graph API Explorer does not work in IE8.
I can’t find much else on this topic which seems to say I am doing something horribly wrong. Or have developers given up on IE < 9?
A straight up GET request doesn’t work in IE 8 because IE 8 can’t understand the JSON format that the data is coming back in and so it crashes. For the AJAX response, you should set the AJAX reponse to
application/json, nottext/javascript. Is there a reason you can’t just use the Facebook JS SDK? For example:I’m not actually sure why the Graph API explorer isn’t working in IE 8, but for me, the explorer throws Javascript errors but doesn’t crash the browser, while loading a Graph response via a GET results in a browser crash.