facebook follow and like api subscription event code (edge.create not working)

时光怂恿深爱的人放手 提交于 2019-12-11 05:46:58

问题


I've implemented liking a website url along with attaching the edge.create event to it. I implemented the follow button but did not get the edge.create to function when clicking to follow button. Also, I cannot figure out how to like a specific facebook page and as well get the edge.create event to subscribe.

I have the following code for when a user performs a LIKE on our website (not the facebook page):

This code works well

    window.fbAsyncInit = function() {
        FB.init({
          appId            : 'xxxxxx',
          autoLogAppEvents : true,
          xfbml            : true,
          version          : 'v2.9'
        });
        FB.AppEvents.logPageView();
        FB.Event.subscribe('edge.create', function(response) {
          alert(1);
         });
      };

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

      <div class="fb-like" data-href="https://www.facebook.com/fbpage" data-layout="standard" data-action="like" data-show-faces="true"/>
    }

Here is my code for following a facebook page , which works but does not fire the edge.create code

      window.fbAsyncInit = function() {
        FB.init({
          appId            : 'xxxxx',
          autoLogAppEvents : true,
          xfbml            : true,
          version          : 'v2.9'
        });
        FB.AppEvents.logPageView();
        FB.Event.subscribe('edge.create', function(response) {
          alert(1);
        });    
      };

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

      <div class="fb-follow" data-href="https://www.facebook.com/fbpage" data-layout="standard" data-size="small" data-show-faces="true"/>

As you can see, I need help getting the edge.create to function with clicking follow button and if possible a way to like a specific facebook page along with the edge.create event code.

来源:https://stackoverflow.com/questions/44399130/facebook-follow-and-like-api-subscription-event-code-edge-create-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!