Facebook API, Canvas app in iFrame, Javascript API, Broken in IE8?
I tried to look for help in the FB forums for this, but they really are not much help there.
My app is set up as an iframe app, but the same behavior happens if the app is set up as an fbml app and the page below is loaded through a fb:iframe. The same behavior exists regardless of what advanced settings are used. The same behavior exists with a simple FB.init (seen below) or with an async call to it.
My site URL is properly set to http://foo.mysitenamehere.foo/ which is the location of this file.
This is the entirety of my app right now: Code:
<html>
<head>
<script src="http://connect.facebook.net/en_US/all.js"></script>
</head>
<body>
<div id="fb-root"></div>
<script type="text/javascript">
FB.init({
appId : '127717367239744',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
alert("FB: " + FB + " FB.getSession(): " + FB.getSession());
FB.getLoginStatus(function(response) {
if (response.session) {
alert("1");
} else {
alert("2");
}
});
</script>
</body>
</html>
Here is what happens:
BEHAVIOR IN WORKING BROWSERS (Firefox, Chrome, Safari PC & Mac, some users of IE) The first session alert and the alert "1" appears in all these browsers. If I examine the requests (using firebug or fiddler2), in every working browser, including IE when it works, the request to login_status.php is a long GET request.
开发者_StackOverflowBEHAVIOR IN BROKEN IE The first session alert shows that session is null/undefined. Looking at the requests the login_status.php is a POST instead of a GET request. This POST request is usually over 4000 characters long. This request originates from all.js.
login_status.php is returning this: Code:
HTTP/1.1 200 OK
Content-Type: text/plain;charset=utf-8
X-Cnection: close
Date: Fri, 27 Aug 2010 20:50:40 GMT
Content-Length: 22
Invalid Application ID
Obviously my app ID is valid (see the other 4 working browsers), rather the POST request is mangled or not accepted by login_status.php, so the response fails and the app is broken in IE.
This is a very distressing issue. My app could not be stripped down to a more simple example, and yet it is not working. Is every canvas iframe app exhibiting this behavior in IE? If not, what on earth is different about what I am doing?
Thanks in advance for any advice.
This was broken for me as well until I changed one of the advanced settings. Go to your advance setting tab and enable the "POST for Canvas" option. This caused other issues but I was able to get past the issue you were having.
You may not have Flash installed. Apparently the Facebook API requires Flash for just some versions of IE. In my testing I've found that to be true, returning the same error message which you're seeing: "Invalid Application ID".
Further Reading:
Facebook Connect integration: does it require flash?
http://forum.developers.facebook.net/viewtopic.php?id=75095 (last few posts)
精彩评论