Facebook 分享链接 - 可以自定义消息正文吗?

发布于 2024-10-18 04:16:47 字数 253 浏览 1 评论 0原文

我正在尝试创建一个在 Facebook 上共享页面的链接。到目前为止,我已经得到:

href="http://www.facebook.com/sharer.php
?u=http%3A%2F%2Fwww.cnn.com%2F
&t=CNN%26s+website"

但是,我真的很想添加一些文本,这些文本将放入“您在想什么?”文本框(尤其是 t 值被链接的标题覆盖)。有谁知道这是否可能?

I'm trying to create a link that will share a page on Facebook. So far I've got:

href="http://www.facebook.com/sharer.php
?u=http%3A%2F%2Fwww.cnn.com%2F
&t=CNN%26s+website"

However, I'd really like to add some text that will go in the 'What's on your mind?' text box (especially as the t value gets overridden by the link's title). Does anyone know if this is possible?

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

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

发布评论

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

评论(7

泪冰清 2024-10-25 04:16:48

注意: @azure_ardee 解决方案不再可行。 Facebook 不允许开发者预先填写消息。开发者可以通过提供 OG 元标签来定制故事,但由用户来填写消息。

仅当您代表用户发布时,这才可能实现,这需要用户使用 publish_actions 权限。即使如此:并且

请注意,Facebook 建议使用用户发起的共享模式。


看看这个答案

NOTE: @azure_ardee solution is no longer feasible. Facebook will not allow developers pre-fill messages. Developers may customize the story by providing OG meta tags, but it's up to the user to fill the message.

This is only possible if you are posting on the user's behalf, which requires the user authorizing your application with the publish_actions permission. AND even then:

please note that Facebook recommends using a user-initiated sharing modal.


Have a look at this answer.

守不住的情 2024-10-25 04:16:48

不能使用sharer.php 执行此操作,但是您可以使用Dialog API 执行类似的操作。 http://developers.facebook.com/docs/reference/dialogs/

http://www.facebook.com/dialog/feed?  
app_id=123050457758183&  
link=http://developers.facebook.com/docs/reference/dialogs/&
picture=http://fbrell.com/f8.jpg&  
name=Facebook%20Dialogs&  
caption=Reference%20Documentation& 
description=Dialogs%20provide%20a%20simple,%20consistent%20interface%20for%20applications%20to%20interact%20with%20users.&
message=Facebook%20Dialogs%20are%20so%20easy!&
redirect_uri=http://www.example.com/response

< img src="https://i.sstatic.net/bQxh0.png" alt="Facebook 对话框示例">

问题是您必须创建一个虚拟 Facebook 应用程序才能拥有 app_id。请注意,您的 Facebook 应用程序根本不需要执行任何操作。只要确保它配置正确,就可以了。

2021 年 11 月更新

Dialog API 的 feed 部分不再包含消息中的 message 字段。它未包含在提要对话框文档中。 picturenamecaptiondescription 字段现已弃用。

因此,为了共享到墙上,您最好使用 sharer.php,它不需要需要 app_id,并且因此不需要注册应用程序:

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

You can't do this using sharer.php, but you can do something similar using the Dialog API. http://developers.facebook.com/docs/reference/dialogs/

http://www.facebook.com/dialog/feed?  
app_id=123050457758183&  
link=http://developers.facebook.com/docs/reference/dialogs/&
picture=http://fbrell.com/f8.jpg&  
name=Facebook%20Dialogs&  
caption=Reference%20Documentation& 
description=Dialogs%20provide%20a%20simple,%20consistent%20interface%20for%20applications%20to%20interact%20with%20users.&
message=Facebook%20Dialogs%20are%20so%20easy!&
redirect_uri=http://www.example.com/response

Facebook dialog example

The catch is you must create a dummy Facebook application just to have an app_id. Note that your Facebook application doesn't have to do ANYTHING at all. Just be sure that it is properly configured, and you should be all set.

November 2021 update

The feed part of the Dialog API no longer includes the message field in the message. It is not included in the feed dialog documentation. The fields picture, name, caption, and description are now deprecated.

Therefore, for the purpose of sharing to the wall, you're better off with sharer.php, which does not require an app_id, and therefore does not need registering an app:

http://www.facebook.com/sharer.php?u=https://example.com
傾城如夢未必闌珊 2024-10-25 04:16:48

就像 @Ardee 所说,sharer.php 使用来自元标记的数据,Dialog API 接受参数。 Facebook 已经删除了使用 message 参数的功能,但您可以使用 quote 参数,这在很多情况下都很有用,例如

在此处输入图像描述

https://www.facebook.com/dialog/share?
app_id=[your-app-id]
&display=popup
&title=This+is+the+title+parameter
&description=This+is+the+description+parameter
"e=This+is+the+quote+parameter
&caption=This+is+the+caption+parameter
&href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2F
&redirect_uri=https%3A%2F%2Fwww.[url-in-your-accepted-list].com

只需创建一个应用程序 ID:

https://developers.facebook.com/docs/apps/register

然后确保重定向 url 域在接受的列表中列出该应用程序的域。

Like @Ardee said you sharer.php uses data from the meta tags, the Dialog API accepts parameters. Facebook have removed the ability to use the message parameter but you can use the quote parameter which can be useful in a lot of cases e.g.

enter image description here

https://www.facebook.com/dialog/share?
app_id=[your-app-id]
&display=popup
&title=This+is+the+title+parameter
&description=This+is+the+description+parameter
"e=This+is+the+quote+parameter
&caption=This+is+the+caption+parameter
&href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2F
&redirect_uri=https%3A%2F%2Fwww.[url-in-your-accepted-list].com

Just have to create an app id:

https://developers.facebook.com/docs/apps/register

Then make sure the redirect url domain is listed in the accepted domains for that app.

音盲 2024-10-25 04:16:48

要添加一些文本,我前段时间做了什么,如果您共享的链接是一个您可以修改的页面。您可以向共享页面添加一些元标记:

<meta name="title" content="The title you want" />
<meta name="description" content="The text you want to insert " />
<link rel="image_src" href="A thumbnail you can show" / >

这是一个小技巧。尽管旧的共享按钮已被“喜欢”/“推荐”按钮取代,如果您使用 XFBML 版本,您可以在其中添加评论。她的更多信息:

http://developers.facebook.com/docs/reference/plugins/喜欢/

To add some text, what I did some time ago , if the link you are sharing its a page you can modify. You can add some meta-tags to the shared page:

<meta name="title" content="The title you want" />
<meta name="description" content="The text you want to insert " />
<link rel="image_src" href="A thumbnail you can show" / >

It's a small hack. Although the old share button has been replaced by the "like"/"recommend" button where you can add a comment if you use the XFBML version. More info her:

http://developers.facebook.com/docs/reference/plugins/like/

番薯 2024-10-25 04:16:48

正如 docs 中所述,

<meta property="og:url"           content="http://www.your-domain.com/your-page.html" />
<meta property="og:type"          content="website" />
<meta property="og:title"         content="Your Website Title" />
<meta property="og:description"   content="Your description" />
<meta property="og:image"         content="http://www.your-domain.com/path/image.jpg" />

建议使用图像尺寸:1 200 x 630

Like said in docs, use

<meta property="og:url"           content="http://www.your-domain.com/your-page.html" />
<meta property="og:type"          content="website" />
<meta property="og:title"         content="Your Website Title" />
<meta property="og:description"   content="Your description" />
<meta property="og:image"         content="http://www.your-domain.com/path/image.jpg" />

image size recommended: 1 200 x 630

定格我的天空 2024-10-25 04:16:48

Facebook 不允许您更改“您在想什么?”文本框,当然,除非您正在开发在 Facebook 上使用的应用程序。

Facebook does not allow you to change the "What's on your mind?" text box, unless of course you're developing an application for use on Facebook.

嘿咻 2024-10-25 04:16:48

我认为这在 Dialog API 中是不可能的,它会触发在 Messenger 上启动消息。 (注意:这与接受的答案中的“发布到你的墙”不同,区别在于 /dialog/send 而不是 /dialog/feed)。

例如:

http://www.facebook.com/dialog/send?  
app_id=123050457758183&  
link=http://developers.facebook.com/docs/reference/dialogs/&
redirect_uri=http://www.example.com/response

请参阅Facebook 文档。截至 2021 年 11 月,文档不显示字段 picturenamecaptiondescription:它们是从网站的开放图标签填充。我尝试添加字段message,但未能生成任何文本,但链接仍然重定向到 Messenger。

I don't think this is possible in the Dialog API, which triggers starting a message on Messenger. (Note: this is different from "posting to your wall" in the accepted answer, the difference being /dialog/send instead of /dialog/feed).

For example:

http://www.facebook.com/dialog/send?  
app_id=123050457758183&  
link=http://developers.facebook.com/docs/reference/dialogs/&
redirect_uri=http://www.example.com/response

See the Facebook documentation. As of November 2021, the documentation does not show the fields picture, name, caption, description: they are populated from the Open Graph tags of the website. I tried adding the field message and it failed to produce any text, but the link still redirects to Messenger.

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