如何在Facebook Sharer中显示图像?

时间:2013-06-05 00:58:29

标签: php html facebook

我使用代码显示弹出的Facebook Sharer,但是故障是,图像没有显示。

<?php
    $title="My Wedding Lookbook! | BridalBook.ph 3rd Anniversary Promo";
    $url="http://www.bridalbook.ph/promos/bridalbook-3rd-year-anniv-promo/?preview=1";
    $summary="I just created my dream wedding lookbook! Getting married? Make your own on BridalBook.ph!";
    $image="http://pagsanjanpalmresort.com/moodboards/111.jpg";
?>

<a onClick="window.open('http://www.facebook.com/sharer.php?s=100&amp;p[title]=<?php echo $title;?>&amp;p[summary]=<?php echo $summary;?>&amp;p[url]=<?php echo $url; ?>&amp;&p[images][0]=<?php echo $image;?>', 'sharer', 'toolbar=0,status=0,width=548,height=325');"> 
Share on Facebook. 
</a>

出了什么问题?

2 个答案:

答案 0 :(得分:3)

除了image url和Share url之外的所有其他参数都需要urlencoded。

示例Javascript实现如下

    imageUrl = 'http://pagsanjanpalmresort.com/moodboards/111.jpg';
    shareTitle = 'My%20Wedding%20Lookbook!%20%7C%20BridalBook.ph%203rd%20Anniversary%20Promo';
    desc = 'I%20just%20created%20my%20dream%20wedding%20lookbook!%20Getting%20married%3F%20Make%20your%20own%20on%20BridalBook.ph!';
    url = 'http://www.bridalbook.ph/promos/bridalbook-3rd-year-anniv-promo/?preview=1';

    window.open('http://www.facebook.com/sharer.php?s=100&p[title]=' + shareTitle + '&p[summary]=' + desc + '&p[url]=' + url + '&p[images][0]=' + imageUrl + '', 'sharer', 'toolbar=0,status=0,width=626,height=436');

答案 1 :(得分:0)

Open Graph meta tags,特别是og:image,可能会有所帮助,具体取决于您希望如何显示它。使用开放图表标记,您的网站将显示为带缩略图的链接。点击缩略图将转到网址,而不是在Facebook中显示完整的照片。