Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

facebook

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?

like image 875
Kokodoko Avatar asked Oct 24 '14 11:10

Kokodoko


People also ask

How do I add a Facebook share button in HTML?

To generate a Facebook Share Button, visit https://developers.facebook.com/docs/plugins/share-button and specify the URL you want people to share as well as the width. Then generate the code, and paste it into your site where you want the button to appear.


2 Answers

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; }); 
like image 169
Reza Avatar answered Sep 28 '22 01:09

Reza


It is possible. No need for an FB application for a simple sharing of URL. Create a simple pop up window and use Facebook share dialog.

https://developers.facebook.com/docs/sharing/reference/share-dialog This is still included in their API as of the moment.

window.open("https://www.facebook.com/sharer/sharer.php?u=http://www.gmanetwork.com/news/", "pop", "width=600, height=400, scrollbars=no");
like image 35
Carmela Avatar answered Sep 28 '22 00:09

Carmela