Facebook 分享链接 - 可以自定义消息正文吗?
我正在尝试创建一个在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
注意: @azure_ardee 解决方案不再可行。 Facebook 不允许开发者预先填写消息。开发者可以通过提供 OG 元标签来定制故事,但由用户来填写消息。
仅当您代表用户发布时,这才可能实现,这需要用户使用
publish_actions
权限。即使如此:并且:看看这个答案。
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:Have a look at this answer.
您不能使用sharer.php 执行此操作,但是您可以使用Dialog API 执行类似的操作。 http://developers.facebook.com/docs/reference/dialogs/
< img src="https://i.sstatic.net/bQxh0.png" alt="Facebook 对话框示例">
问题是您必须创建一个虚拟 Facebook 应用程序才能拥有
app_id
。请注意,您的 Facebook 应用程序根本不需要执行任何操作。只要确保它配置正确,就可以了。2021 年 11 月更新
Dialog API
的 feed 部分不再包含消息中的message
字段。它未包含在提要对话框文档中。picture
、name
、caption
和description
字段现已弃用。因此,为了共享到墙上,您最好使用
sharer.php
,它不需要需要app_id
,并且因此不需要注册应用程序: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/
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 themessage
field in the message. It is not included in the feed dialog documentation. The fieldspicture
,name
,caption
, anddescription
are now deprecated.Therefore, for the purpose of sharing to the wall, you're better off with
sharer.php
, which does not require anapp_id
, and therefore does not need registering an app:就像 @Ardee 所说,sharer.php 使用来自元标记的数据,Dialog API 接受参数。 Facebook 已经删除了使用 message 参数的功能,但您可以使用 quote 参数,这在很多情况下都很有用,例如
只需创建一个应用程序 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.
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.
要添加一些文本,我前段时间做了什么,如果您共享的链接是一个您可以修改的页面。您可以向共享页面添加一些元标记:
这是一个小技巧。尽管旧的共享按钮已被“喜欢”/“推荐”按钮取代,如果您使用 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:
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/
正如 docs 中所述,
建议使用图像尺寸:1 200 x 630
Like said in docs, use
image size recommended: 1 200 x 630
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.
我认为这在 Dialog API 中是不可能的,它会触发在 Messenger 上启动消息。 (注意:这与接受的答案中的“发布到你的墙”不同,区别在于
/dialog/send
而不是/dialog/feed
)。例如:
请参阅Facebook 文档。截至 2021 年 11 月,文档不显示字段
picture
、name
、caption
、description
:它们是从网站的开放图标签填充。我尝试添加字段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:
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 fieldmessage
and it failed to produce any text, but the link still redirects to Messenger.