Create a facebook share button using PHP

These days, facebook is very common option to promote your blog or website, In this post, I am going to tell you how we can add a share button for your post or wesite.

For this, you need to have two things : a facebook share image and another is an url.
To create a share button you can go for the following code snippet :

$title=urlencode('Title of the share code ');
$url=urlencode('Your url or website link');
$summary=urlencode('Summery of the thing which you want to share ');
$image=urlencode('url of your image');

You can set these things according to you, you can set the things hardcoded or dynamic too.

<a onClick="window.open('http://www.facebook.com/sharer.php?s=100&amp;p[title]=<?php echo $title;?>&amp;p[summary]=<?php echo $summary;?>&amp;p[url]=<?php echo $url; ?>&amp;&amp;p[images][0]=<?php echo $image;?>','sharer','toolbar=0,status=0,width=548,height=325');" href="javascript: void(0)">
<img style="width:82px;" src="images/facebook_share.png"></a>

Once you put the code into your website (You can put this code wherever you want to show the share button ), you will see the share button on your website and you will be able to share anything on facebook through your website

Enjoy sharing

For more information, you can ask me into comment box


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s