Facebook Connect Access denied on line 22 all.js in IE7/8 - facebook

I created a very, very simple login page using the exact code that is given in the introduction page of the facebook connect website. Every time I try to launch to connect through IE I get an error through javascript asking me if I want to debug a permission denied problem on line 22. Everything works fine in firefox, chrome, etc.
Odd thing is, the same exact error shows up in Hulu the other day when I tried to connect my Hulu account with FB Connect -- the javascript died on a permission denied problem on the same line. I have tried multiple machines (XP, 7 and Vista) and multiple IE browsers (IE7 and 8), same error.
Here is a copy of my code.
<html>
<head>
<title>My Facebook Login Page</title>
</head>
<body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId:'XXXXXXXXXXX', cookie:true,
status:true, xfbml:true
});
</script>
<fb:login-button perms="email,user_checkins">
Login with Facebook
</fb:login-button>
</body>
</html>
This page can be viewed here: http://www.thecmmns.com/facebooktest2.html
Obviously the XXXXX thing is an actual ID on the live site.
Any ideas? I am very surprised I am the only one seeing this since it even happens on Hulu... Anyone else access Hulu or the above site and get access denied with IE7 or IE 8? Any ideas how to fix?

Just add this code before FB.init:
FB.UIServer.setLoadedNode = function (a, b){FB.UIServer._loadedNodes[a.id] = b; }
Read more at my blog.

Change
"https://connect.facebook.net/assets.php/en_US/sdk.js"
to
"https://connect.facebook.com/assets.php/en_US/sdk.js"
That will be ok.
It's weird that Facebook doesn't update their document.

Related

Redirecting from htm

My client has an old website on freeserve.co.uk (dodgy and free, now belongs to Orange but no support). I want to redirect all pages on the old site to newdomain/index.php. The index page on the old site is index.htm, however most other pages are .html.
Whatever I try the 301 redirect doesn't seem to work. Has anyone come across freeserve before?
You want to redirect the user when they load the page, here are some examples.
Here's the main example
<head>
<script type="text/javascript">
<!--
window.location="http://www.newlocation.com";
//-->
</script>
</head>
but there are a few other options depending what behaviour you're after.

Linkedin apply button plugin not logging in on IE8

I asked this on the linkedin forum a few days ago, but no response there and nothing in a general web search, so trying here.
i I have an apply button test page at http://solomon.ie/li/ (HTML below also).
On IE8/WinXP if I hit apply, while not logged into my Linkedin account, I get the sign in screen/lightbox, hit Sign in button, get the login form popup, enter my details and the screen flashes. But, instead of getting my profile summary and confirm application , I am back to the the sign in screen/lightbox.
If I am already logged in and hit apply it works as normal. Works fine on IE9 and FF and Chrome.
I reset IE8 to default security settings and cleared cache/cookies. No error messages.
Thanks,
Kevin
--
<html>
<head>
<title> New Document </title>
</head>
<body>
<script src="http://platform.linkedin.com/in.js" type="text/javascript">
api_key: dhap7citpirm
</script>
<h1>solomon test job ie</h1>
<script type="IN/Apply" data-companyid="892056" data-jobId="Cj-222234"
data-jobtitle="Test job 4"
data-jobLocation="Dublin Ireland"
data-questions='[{"question": "Can you drive?"},{"question": "Do you have a SAFEPASS?"}]'
data-email="nospam#gmail.com"></script>
</body>
</html>

Facebook iFrame canvas app PHP sessions issue

I've been working on a problem for the last day and a half now and have still yet to find a solution.
When visitng my game on facebook (which is in facebook's iFrame) php sessions don't work. This is for IE and Safari. Chrome works fine.
I've already read all the posts on stack about this problem, which seems to be down to third party cookie security and needing interaction with the iFrame first. There was a workaround by making javascript post some form data to the iFrame first, but this seems to have been 'fixed' in the latest versions of the browsers very recently as this no longer works.
I even tried implementing a start page that would require them to click a link first (in the iFrame) to load another page which would then create the session. But even THAT doesn't work.
I'm also having trouble even loading new pages in the iFrame using javascript, which seems to always cause infinite loop refreshes.
And no, P3P headers do NOT solve it.
Does anyone have a solution to this problem? I can't be the only one with it, considering how many facebook apps exist!
I came across this problem using a client that had "Accept third party cookies" disabled. My solution was to force PHP to embed the session ID into the URI by putting this line at the start of each page:
ini_set('session.use_trans_sid', true);
As the URLs are in iframe within Facebook the SID is not seen in the top window.
For IE, you will need the P3P Headers set. Something like:
<?php header('P3P: CP="CAO PSA OUR"'); ?>
Safari blocks 3rd-party cookies by default. Currently, the only work-around that is working for me is to "pop-up" a new window to set the cookies. I have something like this:
<script type="text/javascript">
function safariFix(){
if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1){
window.open('https://yourdomainname.com/safari.php', 'Safari Fix','width=100,height=100');
}
}
</script>
And safari.php will have this:
<?php
setcookie("safari_test", "1");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Safari Fix</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
</head>
<script type="text/javascript">
$(document).ready(function(){
window.close();
});
</script>
<body>
Since Safari does not accept third-party cookies by default, we are forced to open this window.
This window will automatically close once we have set the cookies.
</body>
</html>
PROBLEM: This won't work if users have "block pop-ups" enabled in Safari. If anyone has a better solution for this, inform me ;)

Integrating facebook Channelurl into Javascript which enables xhtml validation

I use a script I got from the thread below, and adapted slightly
New Facebook like button HTML validation
however the channelurl doesn't work(lots of fd_fragment and multiple visits 10s apart) and I am not 100% convinced about the provenance or the effectiveness of the code, though it does leave me with valid xhtml,
I have tested the like function and it works for me, but I keep seeing "like" operations in my analytics that don't translate into visible "likes" from visitors
furthermore, I find no ref to "fbcont" in facebook literature
Sadly, javascript/ajax is not yet comfortable for me so i'm fumbling a bit here
Can anyone enlighten me about whats wrong with the code
Thanks
My Code:
<div id="FbCont">
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1" type="text/javascript">
</script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
var fb = document.createElement('fb:like');
fb.setAttribute("href","http://www.mydomainname.com");
fb.setAttribute("send","true");
fb.setAttribute("action","like");
fb.setAttribute("layout","button_count");
fb.setAttribute("show_faces","true");
fb.setAttribute("width","100");
fb.setAttribute("font","");
fb.setAttribute("channelUrl","http://www.mydomainname.com/channel.html");
document.getElementById("FbCont").appendChild(fb);
//--><!]]>
</script>
</div>

FB.login dialog does not close on Google Chrome

I'm calling FB.login() on a click event in my application. The dialog pops up as expected, but when the user is done logging into Facebook (and/or authorizing the app), the dialog does not close. Instead it loads a white page (inside the dialog) and the title changes to XD Proxy.
This only happens on Google Chrome (I'm using the latest version available right now for Windows 7).
This doesn't happen if Chrome is in Incognito mode.
The fb-login 'social plugin' works fine on Chrome.
To test/debug this further, I created a new Facebook App with vanilla settings. The only change I made was set the Site URL in the app settings. Here's HTML code that you can use to recreate this bug.
Sample Code for recreating issue
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Chrome Bug Test</title>
</head>
<body>
<button onclick="dologin()">Login using Facebook</button>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : '[YOUR APP ID HERE]',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
</script>
<script type="text/javascript">
function dologin(){
FB.login(function(r){
if(console && console.log) {
console.log(r);
}
});
}
</script>
</body>
</html>
Facebook Settings that I've tried changing
Setting a site domain, didn't change anything.
Using a custom channelUrl and channel file, didn't help either.
Related bugs tracked at Facebook
http://bugs.developers.facebook.net/show_bug.cgi?id=14789
https://github.com/facebook/connect-js/issues/269
http://bugs.developers.facebook.net/show_bug.cgi?id=12112
http://developers.facebook.com/bugs/278247488872084
Related issues here on Stack Overflow
Blank popup with FB connect
facebook connect blank pop up on chrome
Facebook Connect Login redirecting in Chrome and Safari
https://stackoverflow.com/questions/4423718/blank-page-with-fb-connect-js-sdk-on-after-permission-request
Facebook connect showing blank popup on login in Internet explorer 8
Facebook login popup window stays open when using Fb.login in IE
JS SDK FB.login() works but pop-up dialog is staying open after logged in
Facebook login hangs at "XD Proxy" when page is installed via Chrome Web Store
XD Proxy Facebook
XD_Proxy popup won't close
I've seen many people come across this, but what bugs me is that I haven't been able to find a concrete fix for this. Facebook hasn't responded to bug reports yet. One solution would be get rid of Javascript based authentication code and do it solely using serverside mechanism (Facebook PHP SDK). I'd like to avoid that due to time constraints.
Anyone have any ideas how to fix this?
I got a similar call to FB.login() to close the dialog box by changing
onclick="dologin()"
to
onclick="dologin(); return false;"
Given the age of this post, I am guessing that the poster has solved this; however, given that this is also a resource for others searching to resolve similar issues, I thought that I would include my experience just in case.
I found out that what was causing this same issue symptom for me was accidentally forgetting to include event.preventDefault(); in my "click" listener handler in jQuery. The facebook login dialog was popping up and allowing me to log in but not disappearing. The issue was that the website was performing the default form post action, which was interfering with the facebook call-back function.
I had the same exact problem. I did two things, first I added this line right before the FB.init() call:
FB.Flash.hasMinVersion = function () { return false; };
Then I went into the FB app page and added the Site Domain (i.e. test.com).
I think the site domain setting was the key, but I am not 100% positive. All I know is that it seems to always close now in all browsers including Chrome.
Short answer relating to question above:
Load the all.js script over https.
<script src="https://connect.facebook.net/en_US/all.js"></script>
Longer answer if you are troubleshooting a similar issue to the original question:
Use Google Chrome to attempt the login. Once you have logged in and have the blank pop-up window hanging up on the screen, press F12. This brings up the developer tools for Chrome. Click the Console tab, and you will hopefully see the error. What you will likely see is related to XD (cross-domain) issues.
Even if your particular issue is different from the issue I was having, the above should lead you in the right direction.
My issue/solution was specific the Facebook C# SDK v6 documentation - the tutorial code loads the all.js script using a URL that begins with // - which then loads the script from the same scheme as my site (which was http). After I logged in, the pop-up tried to redirect me back from the https Facebook login to my http site and bingo, we have the XD issue. The solution was to specifically load the scripts from https://connect.facebook.net/en_US/all.js as follows:
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "https://connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
Edit:
After some consideration, this approach of allowing a redirect to http might compromise the security of the system by allowing the data in that request to be read by someone else and then to be re-used. I couldn't find any relevant documentation or examples and so I could not conclude one way or another, YMMV.
Calling this snippet after FB.init fixed the issue for me. But other solutions seem to have worked for different cases.
$.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());
if ($.browser.chrome || $.browser.msie) {
FB.XD._origin = window.location.protocol + "//" + document.domain + "/" + FB.guid();
FB.XD.Flash.init();
FB.XD._transport = "flash";
} else if ($.browser.opera) {
FB.XD._transport = "fragment";
FB.XD.Fragment._channelUrl = window.location.protocol + "//" + window.location.host + "/";
}
I've been experiencing the same issue in IE9, and it seemed to stem from upgrading to Flash Player 10. The answers suggested already did not work for me and I'd lost hope in trying to fix it since finding an open bug at Facebook covering it. But Henson has posted an answer on a similar question that fixed it for me. In the JavaScript in my site master I removed these lines
FB.UIServer.setLoadedNode = function (a, b) {
//HACK: http://bugs.developers.facebook.net/show_bug.cgi?id=20168
FB.UIServer._loadedNodes[a.id] = b;
};
and now it works. (N.B. I have not checked to see if the IE8 issue those lines were intended to overcome returns.)