简体   繁体   English

从页面在Facebook上共享图像

[英]Image Sharing on Facebook from a page

My webpage has an image slider. 我的网页上有一个图像滑块。 Each image comes with a FB share button. 每个图像都有一个FB共享按钮。 When i click on a share button i want the particular image to get posted along with the current URL. 当我单击共享按钮时,我希望将特定图像与当前URL一起发布。 I have used the script below: 我使用了以下脚本:

<script type="text/javascript">
function fbShare(url, title, descr, image, winWidth, winHeight) {
var winTop = (screen.height / 2) - (winHeight / 2);
var winLeft = (screen.width / 2) - (winWidth / 2);
window.open('http://www.facebook.com/sharer.php?s=100&p[title]=' + title + '&p[summary]=' + descr + '&p[url]=' + url + '&p[images][0]=' + image, 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width='+winWidth+',height='+winHeight);
}
</script>

But it does not select the image and is selecting some random text instead of the text in page body. 但是它不会选择图像,而是选择一些随机文本而不是页面正文中的文本。

Please help. 请帮忙。 Thanks in advance. 提前致谢。

sharer.php only takes the URL as parameter, all other data (title, image, ...) will come from the Open Graph tags of that URL: sharer.php仅将URL作为参数,所有其他数据(标题,图像等)将来自该URL的Open Graph标记:

https://www.facebook.com/sharer/sharer.php?u=encodedurl

More information about Open Graph tags: 有关“打开图”标签的更多信息:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM