Created
June 21, 2012 14:06
-
-
Save youtalk/2965939 to your computer and use it in GitHub Desktop.
Get the numbers of Facebook's likes and comments through Graph API
This file contains hidden or 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
$.getJSON('https://graph.facebook.com/' + location.href, function (json) { | |
if (json) { | |
if (json.shares && json.shares > 0) { | |
$('a#fb-like > span > span.ui-btn-text') | |
.text($('a#fb-like').text().split(' ')[0] + ' ' + json.shares); | |
} | |
if (json.comments && json.comments > 0) { | |
$('a#fb-comment > span > span.ui-btn-text') | |
.text($('a#fb-comment').text().split(' ')[0] + ' ' + json.comments); | |
} | |
} | |
}); |
This file contains hidden or 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
<div data-role="controlgroup" data-type="horizontal"> | |
<a href="/like" data-role="button" id="fb-like" | |
data-theme="b" data-icon="facebook" data-rel="dialog">いいね</a> | |
<a href="/comment" data-role="button" id="fb-comment" | |
data-theme="b" data-icon="facebook" data-rel="dialog">コメント</a> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment