大家好,我在使用“赞”按钮时遇到了问题。我遵循了https://developers.facebook.com/docs/reference/plugins/like/中的每一步。我已经应用了一些我在网上找到的解决方案,包括在 js.src 中附加“https”的解决方案。代码如下,希望对大家有所帮助。^^
<html
xmlns = "http://www.w3.org/1999/xhtml"
xmlns:og = "http://ogp.me/ns#"
xmlns:fb="http://ogp.me/ns/fb#">
<?php
$title = "This is a Title.";
$type = "movie";
$url = "http://www.200909630.site11.com/share.php";
$image = "http://i3.kym-cdn.com/photos/images/original/000/264/615/242.png";
$description = "This is a description.";
?>
<head>
<title>Fund My Travel</title>
<meta property = "og:title" name = "title" content = "<?php echo $title; ?>" />
<meta property = "og:type" name = "type" content = "<?php echo $type; ?>" />
<meta property = "og:url" name = "url" content = "<?php echo $url; ?>" />
<meta property = "og:image" name = "image" content = "<?php echo $image;; ?>" />
<meta property = "og:description" name = "description" content = "<?php echo $description; ?>" />
<script type = "text/javascript" src = "http://static.ak.fbcdn.net/connect.php/js/FB.Share"></script>
<script type = "text/javascript">
var buttons = document.getElementsByName('fb_share');
var count = buttons.length;
for(var i = 0; i<count; i++) {
var data = FB.Share.getUrl(buttons[i]);
if(FB.Share.results[data]) {
buttons[i].fb_count = FB.Share.results[data].total_count;
}
FB.Share.displayBox(buttons[i], 0);
}
</script>
<script>
!function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if( !d.getElementById(id) ) {
js = d.createElement(s);
js.id = id;
js.src = "//platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
}
}
(document, "script", "twitter-wjs");
</script>
<script type="text/javascript">
window.___gcfg = {lang: 'en-GB'};
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</head>
<body>
<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/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<table cellspacing = "3" cellpadding = "3">
<tr>
<fb:like send = "false" width = "450" show_faces = "false"></fb:like>
</tr>
<tr>
<td>
<a name = "fb_share"></a>
</td>
<td>
<a href = "https://twitter.com/share" class = "twitter-share-button" data-lang = "en"
data-url = "<?php echo $url; ?>" data-text = "<?php echo $title; ?>"></a>
</td>
<td>
<g:plusone size = "medium"></g:plusone>
</td>
</tr>
</table>
</body>
</html>