FB like button edge.create event not firing after login

I have fb like button on my site, below is my code

<fb:like  ref="bartastico_fblike" href="https://www.facebook.com/Wetechies" layout="button_count" action="like" show_faces="false" share="false"></fb:like>

window.fbAsyncInit = function() {
      console.log("init");
            FB.init({
                appId: 'xxxx', 
                status: true,
                cookie: true,
                oauth: true,
                xfbml: true
            });
   var page_like_or_unlike_callback = function(url, html_element) {
  console.log("page_like_or_unlike_callback");
  console.log(url);
  console.log(html_element);
};


FB.Event.subscribe('edge.create', page_like_or_unlike_callback);

  };


(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;js.async = true;
  js.src = "//connect.facebook.net/en_US/all.js";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

the issue is edge.create is not firing when first time user clicks on like button and log in and Even I tried statuschange and authresponsechange events no event is getting fired for first time.

But after that if I unlike and like the event fires properly.

Am using this inside php file within js script tag. I have changed my localhost to www.example.com so my siteurl is http://www.example.com and domain is www.example.com in app settings.

live example - http://jsfiddle.net/JY89q/

clear your cache then click on the like button and login, like button doesn't turn to confirm in fiddle. repeat same thing couple of times - clean-like-login. its not consistent it fires up once in a while.

Answers:

Answer

Well, Nobody knows the answer except facebook.

Yes its a bug! already reported but not been assigned by facebook to anybody to work on it yet.

Answer

I have the same problem and didn't find an answer in months. I can give you a dirty workaround which works in desktop browsers sadly not on mobile:

You have to check for auth.login instead of edge.create. Inside the auth.login callback call the edge.create action. Inside the edge.create action you can now define your callback to redirect or do anything you like.

//If not logged in
FB.Event.subscribe('auth.login', login_event);
//If already logged in just call edge.create
login_event();

//edge create event
var login_event = function(){
    FB.Event.subscribe('edge.create', page_like_callback);
}

var page_like_callback = function(){
    //Do your stuff
    location.href = url;
}

I know this is pretty dirty but like this my like-gate works fine on desktop browsers. The only problem is if the user is not logged in but already liked your page - you won't be able to catch this case sadly.. But I agree - edge.create not triggering if not logged in seems to be a bug imo as well.

Btw. I'm using the auto init function instead of the FB.init()..

js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appID=12321321321321&version=v2.0";

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.