简体   繁体   English

JavaScript Facebook共享选项

[英]JavaScript Facebook share options

I have a task to make things with social networks. 我有一项任务是用社交网络制作东西。

As far as I have discovered, there are 2 options. 据我所知,有两种选择。 One is through your News Feed and the other is through the Sharer. 一个是通过您的新闻Feed,另一个是通过Sharer。 In the diagram below, I show both. 在下图中,我展示了两者。 第一个要求你把它贴在你的墙上,第二个要求你分享它。
The first uses dialog/feed, and the second uses sharer.php. 第一个使用dialog / feed,第二个使用sharer.php。

There is a difference as to how content is shared. 内容如何共享存在差异。 The first shares it how I would like it, the second shows it in a way that I dislike. 第一个分享它我想要它,第二个以我不喜欢的方式显示它。 第一个要求你把它贴在你的墙上,第二个要求你分享它。

I do not like the fact that the second one shares the whole page. 我不喜欢第二个共享整个页面的事实。 I want that share icon for every image in the page and to share that specific icon, but not the whole page. 我想为页面中的每个图像分享共享图标并共享该特定图标,但不是整个页面。 Is it possible to make the share icon to look like the second image, but share content like the first? 是否可以使共享图标看起来像第二个图像,但共享内容像第一个? How should it look in Javascript/HTML? 它应该如何看待Javascript / HTML?

If you need any code, that I used, just ask. 如果您需要我使用的任何代码,请询问。

For the second option to look like the first one - and to use a specific image - you have to use Open Graph tags in the shared URL: http://ogp.me/ 对于第二个看起来像第一个选项 - 并使用特定图像 - 您必须在共享URL中使用Open Graph标记: http//ogp.me/

The second option is made with the "sharer.php", i guess. 我想,第二个选项是使用“sharer.php”。 It just takes the URL of the site as parameter, the rest of the information is loaded from the Open Graph tags in the page. 它只是将站点的URL作为参数,其余信息从页面中的Open Graph标签加载。 You can also define more than one share icon btw, so the user can browse through them before sharing. 您还可以定义多个共享图标btw,以便用户可以在共享之前浏览它们。

For example, if you want a specific image to show up, you need this tag: 例如,如果要显示特定图像,则需要以下标记:

<meta property="og:image" content="http://mydomain.com/myimage.jpg" />

Btw, you can always test the Open Graph tags in the Facebook debugger: 顺便说一下,你总是可以在Facebook调试器中测试Open Graph标签:

https://developers.facebook.com/tools/debug https://developers.facebook.com/tools/debug

It also refreshes the tags, if they don´t show up correctly in the share window, just put the link into the debugger again. 它还刷新标签,如果它们没有在共享窗口中正确显示,只需将链接再次放入调试器即可。

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

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