Search code examples
facebook

How create a Facebook share button without SDK or custom app id?


I am looking at the latest update to Facebook's share button. It seems that it's no longer possible to include a share button in a website without including the Facebook javascript SDK, or having a Facebook app somewhere that provides you with an app id?

Share button example 1 uses the Facebook SDK

FB.ui({
  method: 'share',
  href: 'https://developers.facebook.com/docs/',
}, function(response){});

Share button example 2 uses a custom app id

https://www.facebook.com/dialog/share?
  app_id=145634995501895
  &display=popup
  &href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2F
  &redirect_uri=https%3A%2F%2Fdevelopers.facebook.com%2Ftools%2Fexplorer

Question: how to build a plain and simple share button for Facebook with one line of code, that does not require libraries and app id's?


Solution

  • you can use facebook sharer link and a simple popup to do the job

    $("#facebookShareLink").on("click",function(){
        var fbpopup = window.open("https://www.facebook.com/sharer/sharer.php?u=http://stackoverflow.com", "pop", "width=600, height=400, scrollbars=no");
        return false;
    });