Php tutorials

Share Your Website Post To Social Media using php

Google+ Pinterest LinkedIn Tumblr

Share Your Website Post To Social Media using php

Share your website post to social media using php. Everyone want to share their post in social media regularly to get increase the page views and also website view. So the social media is the best way to promote our content to reach everyone. When ever we write our post we directly update this post into our social media using php

Here I am written sharing code, Just click social media icons it will share automatically to your social media timeline

Here I have get our website details description and content using php

<?php $url="";
$name="Share post links articles to social network with Yoursite"; 
$caption="social sharing developer desks"; 
$description="Write some fo the description about your content."; 
$logo=""; ?>

Here we going to add Facebook and Google plus sharing

<title>Share links | Developerdesks</title>
<div class="gplus">
<!--google+ sharing --> 
<a href="{<?php echo $url;?>}" onclick=", '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;">
<img width="200" src="google+.png"/> </a> 
<!--/google+ sharing --> 
<div class=""fb-class">
<!-- fb sharing -->
<a href="#" id="shareonfacebook"><img src="facebook.jpg"></a>
<div class="fb-share-button" data-href="<?php echo $url; ?>" data-layout="button_count">
</div> </body> </html>

Add Javascript for sharing link
Het your facebook api id from the developers facebook page

Find how to get app id – Here

<script src="//"></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 $url; ?>';  e.preventDefault(); FB.ui( { method: 'feed', name: name, link: link, caption: caption, picture: picture, description: description, message: '' }); }); });  </script> <script> FB.init({appId: 'yourappid', 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); = id; js.src = "//"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script>

Here we added the javascript for post article. now you can used ur post to share in social media

I'm Rajasekar - Web developer, Freelancer, Blogger and Owner of DeveloperDesks. From India lives in Bahrain. I love to do coding, Creating websites and trying different with code and designs. You Can Hire Me