Facebook/Twitter share button with url,title and image
1.Create a facebook share button with url,title and image:
First of all you need to add og meta tag in your header
like:
<meta property="og:title" content="Your Title">
<meta property="og:image" content="Your image url">
<meta property="og:url" content="Your Url">
Now Add Facebook share button
<?php
$title=urlencode('Your Title');
$url=urlencode(URL::to('Your Url'));
$image=urlencode('Your image url');
?>
<a onClick="window.open('http://www.facebook.com/sharer.php?s=100&p[title]=<?php echo $title;?>&p[url]=<?php echo $url; ?>&&p[images][0]=<?php echo $image;?>', 'sharer', 'toolbar=0,status=0,width=548,height=325');" target="_parent" href="javascript: void(0)">
Share our Facebook page!
</a>
NOTE:
If any Problem share url you can check your bug using this url
https://developers.facebook.com/tools/debug/?ref=u2u
2.Create a twitter share button with url,title and image:
First of all you need to add twitter card your header
like:
<meta property="og:title" content="Your Title">
<meta property="og:image" content="Your image url">
<meta property="og:url" content="Your Url">
<meta name="twitter:card" content="summary"></meta>
Now Add Twitter share button
<?php
$title=urlencode('Your Title');
$url=urlencode(URL::to('Your Url'));
$image=urlencode('Your image url');
?>
<a href="http://twitter.com/share?text=$title&url= $url">Twitter</a>
1.Create a facebook share button with url,title and image:
First of all you need to add og meta tag in your header
like:
<meta property="og:title" content="Your Title">
<meta property="og:image" content="Your image url">
<meta property="og:url" content="Your Url">
Now Add Facebook share button
<?php
$title=urlencode('Your Title');
$url=urlencode(URL::to('Your Url'));
$image=urlencode('Your image url');
?>
<a onClick="window.open('http://www.facebook.com/sharer.php?s=100&p[title]=<?php echo $title;?>&p[url]=<?php echo $url; ?>&&p[images][0]=<?php echo $image;?>', 'sharer', 'toolbar=0,status=0,width=548,height=325');" target="_parent" href="javascript: void(0)">
Share our Facebook page!
</a>
NOTE:
If any Problem share url you can check your bug using this url
https://developers.facebook.com/tools/debug/?ref=u2u
2.Create a twitter share button with url,title and image:
First of all you need to add twitter card your header
like:
<meta property="og:title" content="Your Title">
<meta property="og:image" content="Your image url">
<meta property="og:url" content="Your Url">
<meta name="twitter:card" content="summary"></meta>
Now Add Twitter share button
<?php
$title=urlencode('Your Title');
$url=urlencode(URL::to('Your Url'));
$image=urlencode('Your image url');
?>
<a href="http://twitter.com/share?text=$title&url= $url">Twitter</a>
No comments:
Post a Comment