Share your website link in social media website. Everyone want to share they website link to social media network. every time they will go social websites after only they post to timeline, Here i am written sharing code, Just click social media icons it will share automatically to your social media timeline. Previously i have posted Share links to social network sites with Your site topic but this one updated.
Php
I have store some sharing data value in php variables.<?php $src="http://www.mostlikers.com"; $name="Share links to social network sites with Yoursite"; $caption="social sharing mostlikers"; $description="This concept share web your page link to social medias."; $picture="http://www.mostlikers.com/logo.png"; ?>
Html
Google+ i have shared url <?php echo $src;?> - it will work offline.Facebook i have shared image,description,url,title - it will work online.
<html> <head> <title>Share links | mostlikers</title> </head> <body> <table> <tr><!--google+ sharing --> <td>
<a href="https://plus.google.com/share?url={<?php echo $src;?>}"
onclick="javascript:window.open(this.href,'', 'menubar=no,
toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;"> <img width="200" src="google+.png"/> </a> </td><!--/google+ sharing --> <td> <a href="#" id="shareonfacebook"><img src="facebook.jpg"></a></td> <td> <div class="fb-share-button" data-href="<?php echo $src; ?>"
data-layout="button_count"></div></a></td> </tr> </table> </body> </html>
Script
Before using below script you need to create facebook app in your pageChange App id (123APPID) to your App id
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script> $(document).ready(function () { $('#shareonfacebook').click(function (e) { var name ='<?php echo $name; ?>'; var caption ='<?php echo $caption; ?>'; var picture ='<?php echo $picture; ?>'; var description ='<?php echo $description; ?>'; var link ='<?php echo $src; ?>'; e.preventDefault(); FB.ui( { method: 'feed', name: name, link: link, caption: caption, picture: picture, description: description, message: '' }); }); }); </script> <script> FB.init({appId: '123APPID', status: true, cookie: true, xfbml: true}); </script> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=123APPID&version=v2.0"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script>
I hope this post helpful for you. If you have any suggestion comment below.
No comments:
Post a Comment