Facebook 如何“分享”?堆栈溢出按钮起作用吗?

发布于 2024-12-06 05:35:24 字数 1258 浏览 0 评论 0原文

我希望在我们的网站上添加社交图标,让客户能够在他们的 Facebook 和 Twitter 个人资料上“点赞”、发推文和分享内容。我注意到在此框的左侧,facebook 和 twitter 图标完全完成了我想要完成的任务,但我不熟悉如何做到这一点。查看源代码,有 JS 引用:

<script type="text/javascript">
  StackExchange.ready(function() {
    var shareUrl = "http%3a%2f%2fstackoverflow.com%2fq%2f7505636%2f337690";
    var shareMsg = "Advice+integrating+Facebook+%27share%27+and+link%2fimage+capabilities+with+our+site";   
    StackExchange.share.facebook($("#fb-share-7505636"), shareUrl, shareMsg);
    StackExchange.share.twitter($("#twitter-share-7505636"), shareUrl, shareMsg);
});
</script>

我们的网站是这样工作的:虽然任何人都可以随时访问主网站,但个人可以使用自己唯一的 URL 注册为代表,该 URL 充当推荐人以给予“信用”关于奖励。我查看了 Facebook 开发者网站,说实话,我有点不知所措。我想让我们的会员能够从他们的仪表板中单击 Facebook 图标,提示他们在墙上发布一组图片、一组标题和描述。我在文档中读到,这是通过在头部设置元标记来完成的,但这对我的网站来说似乎并不重要(或者我显然做错了)。

如果 facebook 正在寻找的 URL(共享 URL)位于受密码保护的页面或网站的某个区域后面,而该区域不允许基于缺失的 PHP SESSION 变量的内容,该怎么办?

编辑

我还在网上看到很多内容说我必须集成 Facebook JS SDK,但随后继续讨论身份验证/在墙上书写的权限等。是的,左侧的链接没有这个网站就是一个完美的例子

上面的链接很棒,但它假设我需要授权“共享”,而该网站上没有发生这种情况。

I am looking to add social icons to our site, giving customers the ability to "like", tweet and share content on their facebook and twitter profiles. I have noticed to the left of this box, the facebook and twitter icons do exactly what I am trying to accomplish but I am not familiar with how to do this. Looking at the source code, there are JS references to:

<script type="text/javascript">
  StackExchange.ready(function() {
    var shareUrl = "http%3a%2f%2fstackoverflow.com%2fq%2f7505636%2f337690";
    var shareMsg = "Advice+integrating+Facebook+%27share%27+and+link%2fimage+capabilities+with+our+site";   
    StackExchange.share.facebook($("#fb-share-7505636"), shareUrl, shareMsg);
    StackExchange.share.twitter($("#twitter-share-7505636"), shareUrl, shareMsg);
});
</script>

Our site works this way: While anybody can visit the primary site at any time, individuals can sign up as representatives with their own unique URL that acts as a referrer to give 'credit' on rewards. I have reviewed the facebook developer site and to be honest I am slightly overwhelmed. I want to give our members the ability to click a Facebook icon from within their dashboard, prompting them to post on their wall with a set image, set title, and description. I have read in the documentation this is done by setting meta tags in the head but it does not seem to matter for my site (or I am clearly doing it wrong).

What if the URL facebook is looking for (share URL) is behind a password protected page or an area of the site which would not allow content based on a missing PHP SESSION variable?

Edit

I have also seen a lot on the net which says I have to integrate the Facebook JS SDK but then goes on to talk about authentication/permission to write on walls, etc. Yes the link to the left does not ask for permission to do anything other than to 1) log into the FB account, 2) post on the user's wall.
This site is a perfect example

The link above is great but it assumes I need to authorize a 'share' which does not occur on this site.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不咬妳我踢妳 2024-12-13 05:35:24

当您单击共享按钮时,您会调用 facebook.com 上的脚本,然后该脚本将依次访问查询字符串 (?u=xxxxxx) 中指向的页面。

Facebook 将解析该页面并抓取它找到的前几张图像、页面的描述和标题。这就是它向您显示的内容,并允许您添加一些附加文本(以及编辑标题/描述/并选择不同的图像)。

如果该页面包含 Facebook 要求您添加到页面的特定元标记,那么他们将使用这些标记来填充标题/描述/图像。这允许网页作者控制他们的页面在 Facebook feed 中的显示方式(尽管用户仍然可以在发布之前对其进行编辑)。这些元标签需要位于 Facebook 使用的特定页面中。

如果 facebook 由于受密码保护等原因而无法访问该页面 - 那么它就无法解析元标记,然后只会向用户显示 URL 作为标题,而没有描述和缩略图。

When you click on the share button, you call a script on facebook.com that will then in turn access the page pointed to in the querystring (?u=xxxxxx).

Facebook will parse that page and grab the first few images it finds, a description and title from the page. That is what it shows to you and allows you to add some additional text (as well as edit the title/description/and choose different images).

If that page contains the specific meta tags that facebook asks you to add to the page, then they'll use those to populate the title/description/image. This allows the webpage author to control how their page shows up in a facebook feed (although the user could still edit it before posting). These meta tags would need to be in that particular page to be used by facebook.

If facebook cannot access the page because it's password protected, etc. - then it cannot parse the meta tags and will then just show the user the URL as the title with no description and thumbnail.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文