Reputation: 21
My website is generate a unique id or link to every user so how I can add share button to let user share his link in FB for example ? My website generate code is :
$uid_code = md5($user);
echo '<br /><center><div id="codewrap">Copy link and share it <br /><code>'.$sksiteurl.'index.php?nav=test&id='.$uid_code.'</code></div></center>';
Upvotes: 0
Views: 10014
Reputation: 2327
First Put a button on where you want to add sharing link like below
<button class="social" data-url="$add-your-page-url" title="Share on Facebook">
<i class="fa fa-facebook"></i>
</button>
Now by this jQuery you can share any page link
<script>
$(document).on('click','.social',function(e){
var url = $(this).data("url");
if(type=="fb") var url = 'http://www.facebook.com/sharer.php?u=';
mini=true&url=';
window.open(url,'',"width=500,height=500,left=400px,top=100px,location=no");
});
</script>
Try this.
Upvotes: 0
Reputation: 1
For reference use this link:
<?php
function fb_count() {
global $fbcount;
$facebook = file_get_contents('http://api.facebook.com/restserver.php?method=links.getStats&urls=https://www.daddydesign.com/how-to-create-a-custom-facebook-share-button-with-a-custom-counter/');
$fbbegin = '<share_count>'; $fbend = '</share_count>';
$fbpage = $facebook;
$fbparts = explode($fbbegin,$fbpage);
$fbpage = $fbparts[1];
$fbparts = explode($fbend,$fbpage);
$fbcount = $fbparts[0];
if($fbcount == '') { $fbcount = '0'; }
}
?>
This will help you! Thanks
Upvotes: 0