php 如何在 Facebook 共享者 URL 中传递标题、摘要和图像等参数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22652041/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to pass a parameter like title, summary and image in a Facebook sharer URL
提问by kamesh
Question:
题:
I need to pass my content like title, summary and image in a Facebook sharer URL like this:
我需要在 Facebook 共享 URL 中传递我的内容,如标题、摘要和图像,如下所示:
<a id="button"
href="http://www.facebook.com/sharer.php?
s=100
&p[url]=http://myurl.com/overview/sap-talent
&p[images][0]=http://myurl/images/my_image.png
&p[title]=mytitle
&p[summary]=containsummary">
The problem is it's automatically getting some content from the above mentioned URL (http://myurl.com/overview/sap-talent), and I don't know where my title and summary data are gone. Is there another way to share my custom title, summary and image via facebooksharer.php
?
问题是它会自动从上面提到的 URL ( http://myurl.com/overview/sap-talent)获取一些内容,而我不知道我的标题和摘要数据去了哪里。是否有另一种方式可以通过 共享我的自定义标题、摘要和图像facebooksharer.php
?
回答by Robert Oates
Looks like Facebook disabled passing parameters to the sharer.
看起来 Facebook 禁止将参数传递给共享者。
We have changed the behavior of the sharer plugin to be consistent with other plugins and features on our platform.
The sharer will no longer accept custom parameters and facebook will pull the information that is being displayed in the preview the same way that it would appear on facebook as a post from the url OG meta tags.
我们已更改共享器插件的行为以与我们平台上的其他插件和功能保持一致。
共享者将不再接受自定义参数,并且 facebook 将提取在预览中显示的信息,就像它在 facebook 上显示为来自 url OG 元标记的帖子一样。
Here's the URL to the post: https://developers.facebook.com/x/bugs/357750474364812/
这是帖子的网址:https: //developers.facebook.com/x/bugs/357750474364812/
回答by i--
This works at the moment (Oct. 2016), but I can't guarantee how long it will last:
这目前有效(2016 年 10 月),但我不能保证它会持续多长时间:
https://www.facebook.com/sharer.php?caption=[caption]&description=[description]&u=[website]&picture=[image-url]
回答by vladkras
The only parameter you need right now is ?u=<YOUR_URL>
. All other data will be fetched from page or (better) from your open graph meta tags:
您现在需要的唯一参数是?u=<YOUR_URL>
. 所有其他数据将从页面或(更好)从您的开放图元标记中获取:
<meta property="og:url" content="http://www.nytimes.com/2015/02/19/arts/international/when-great-minds-dont-think-alike.html" />
<meta property="og:type" content="article" />
<meta property="og:title" content="When Great Minds Don't Think Alike" />
<meta property="og:description" content="How much does culture influence creative thinking?" />
<meta property="og:image" content="http://static01.nyt.com/images/2015/02/19/arts/international/19iht-btnumbers19A/19iht-btnumbers19A-facebookJumbo-v2.jpg" />
You can test your page for accordance in the debugger.
您可以在调试器中测试您的页面。
回答by Marie
On the Developers bugs Facebook site, the last answer about that (parameters with sharer.php
), makes me believe it was a bug that was going to be resolved. Am I right?
在 Developers bugs Facebook 网站上,有关该 ( parameters with sharer.php
)的最后一个答案让我相信这是一个即将解决的错误。我对吗?
https://developers.facebook.com/x/bugs/357750474364812/
https://developers.facebook.com/x/bugs/357750474364812/
Ibrahim Faour · · Facebook Platform Team
Apologies for the inconvenience. We aim to update our external reports as soon as we get a resolution on issues. I do understand that sometimes the answer provided may not be satisfying, but we are eager to keep our platform as stable and efficient as possible. Thanks!
Ibrahim Faour · · Facebook 平台团队
不便之处敬请原谅。我们的目标是在问题得到解决后立即更新我们的外部报告。我确实理解有时提供的答案可能并不令人满意,但我们渴望保持我们的平台尽可能稳定和高效。谢谢!
回答by Darren
I've used the below before, and it has worked. It isn't very pretty, but you can alter it to suit your needs.
我以前用过下面的,它奏效了。它不是很漂亮,但您可以更改它以满足您的需要。
The following JavaScript function grabs the location.href
& document.title
for the sharer, and you can ultimately change these.
以下 JavaScript 函数获取共享者的location.href
& document.title
,您最终可以更改这些。
function fbs_click() {
u=location.href;
t=document.title;
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),
'sharer',
'toolbar=0,status=0,width=626,height=436');
return false;
}
Usage:
用法:
<a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" onclick="return fbs_click()" target="_blank">
Share on Facebook
</a>
It looks like this is what you could possibly be looking for: Facebook sharer title / desc....
看起来这就是您可能正在寻找的内容:Facebook 共享者标题/描述....
回答by Bruja
It seems that the only parameter that allows you to inject custom text is the "quote".
似乎允许您注入自定义文本的唯一参数是“引用”。
https://www.facebook.com/sharer/sharer.php?u=THE_URL"e=THE_CUSTOM_TEXT