我想添加一个facebook分享按钮,但弹出窗口并没有显示正确的参数。这是我的代码:
<?php
$title=urlencode('Title of the iFrame Tab');
$url=urlencode('http://my-domain/index.php?langue=eng&table_pub=publication_eng&id=22&rub=publication');
$summary=urlencode('Custom message here');
$image=urlencode('http://my-domain/img.png');
?>
<a onClick="window.open('http://www.facebook.com/sharer.php?s=100&p[title]=<?php echo $title;?>&p[summary]=<?php echo $summary;?>&p[url]=<?php echo $url; ?>&p[images][0]=<?php echo $image;?>','sharer','toolbar=0,status=0,width=548,height=325');" href="javascript: void(0)">Share</a>
但是这段代码总是向我显示一个这样的弹出窗口:
答案 0 :(得分:0)
Facebook不再支持sharer.php中的自定义参数。
答案 1 :(得分:0)
使用facebook javascript sdk,
window.fbAsyncInit = function() {
FB.init({
appId : '{your-app-id}',
status : true,
xfbml : true
});
};
(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";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
您的分享按钮,
<a href="yoururl" data-image="yourimage" data-title="title" data-desc="Some description" class="fbshare">FBShare</a>
点击按钮,
$('.fbshare').click(function(){
elem = $(this);
postToFeed(elem.data('title'), elem.data('desc'),
elem.prop('href'),
elem.data('image'));
return false;
});