MAK
MAK

Reputation: 775

Facebook send button integration error for website

I'm trying to integrate a Facebook send button into my site using Facebook app. I have created an app in Facebook, and provided my site url in the website link:

I'm using the the following code in my webpage:

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({appId: '1xxxxxxxxxx', status: true, cookie: true, xfbml: true});
  };
  (function() {
    var e = document.createElement('script');
    e.type = 'text/javascript';
    e.src = document.location.protocol + '//connect.facebook.net/en_GB/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
  }());
</script>

<script>
  function trace(message) {
      var div = document.getElementById('trace');
      div.innerHTML = div.innerHTML + message + '<br/>';
  }
</script>

It’s not displaying a window to login for sending mail to friends.

Upvotes: 0

Views: 520

Answers (2)

MAK
MAK

Reputation: 775

I added the javascriptSDK and then Send button code from facebook. The total code follows like this : In my Head :

<script>window.fbAsyncInit = function() { FB.init({ appId : '1xxxxxxxxxxxxx', // App ID channelUrl : 'http://example.com/', // Channel File status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML }); }; // Load the SDK Asynchronously (function(d){ var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "http://connect.facebook.net/en_US/all.js"; d.getElementsByTagName('head')[0].appendChild(js); }(document)); </script><script>(function(d, s, id) {
//IN the Body Section

 <div id="fb-root"></div> <br/> <div class="fb-send" data-href="http://example.com/"></div>

Upvotes: 0

DMCS
DMCS

Reputation: 31880

You're missing the markup for the send plugin. It will look something like this:

<div class="fb-send" data-href="http://example.com"></div>

Also the js.src = line should be like:

js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId={APPID}";

Upvotes: 1

Related Questions