Created
October 23, 2016 18:06
-
-
Save jhouedanou/a8c5f14303b7778d5ab6c4a717f2445c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
var $permalink = $_SERVER['REQUEST_URI']; | |
?> | |
<div class="compteur" data-permalink="<?php $permalink; ?>" style="display: none"> | |
<p> Cet article a été partagé <span class="partages">0</span>fois sur facebook </p> | |
<p>Cet article a été commenté<span class="commentaires" data-url="">0</span></p> | |
</div> | |
<script> | |
(function($) { | |
var permalink = $('.compteur').data("permalink"); | |
updateShareCount(permalink); | |
function updateShareCount (permalink) { | |
return jQuery.ajax({ | |
url: 'https://graph.facebook.com/?id=' + permalink, | |
type: 'GET', | |
dataType: 'JSONP', | |
success: function(data) { | |
//console.log(data); | |
if (data.share) { | |
$( ".partages" ).html( data.share.share_count ); | |
$( ".commentaires" ).html( data.share.comment_count ); | |
//$partages = parseInt(data.share.share_count ); | |
//$commentaires = parseInt(data.share.comment.count); | |
} | |
} | |
}); | |
} | |
}(window.jQuery || window.$)); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment