我正在嘗試創建一個在Facebook上共享頁面的鏈接。到目前爲止,我已經有了:Facebook共享鏈接 - 您可以自定義郵件正文文本嗎?
href="http://www.facebook.com/sharer.php
?u=http%3A%2F%2Fwww.cnn.com%2F
&t=CNN%26s+website"
但是,我真的很想添加一些文字,將在去「什麼是您的想法?」文本框(特別是t
值會被鏈接標題覆蓋)。有誰知道這是否可能?
我正在嘗試創建一個在Facebook上共享頁面的鏈接。到目前爲止,我已經有了:Facebook共享鏈接 - 您可以自定義郵件正文文本嗎?
href="http://www.facebook.com/sharer.php
?u=http%3A%2F%2Fwww.cnn.com%2F
&t=CNN%26s+website"
但是,我真的很想添加一些文字,將在去「什麼是您的想法?」文本框(特別是t
值會被鏈接標題覆蓋)。有誰知道這是否可能?
您不能做到這一點使用sharer.php,但你可以使用類似的對話框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應用程序,只是爲了有一個app_id
。請注意,你的Facebook應用程序根本不需要做任何事情。只要確保它已正確配置,並且您應該全部設置。
這仍然有效嗎?因爲當我轉到你的網址時,消息沒有設置。 – Tim 2012-01-04 16:16:05
Facebook不允許你改變「你在想什麼?」文本框,除非你正在開發一個在Facebook上使用的應用程序。
注意: @azure_ardee解決方案不再可行。 Facebook不會允許開發者預先填寫消息。開發人員可以通過提供OG元標籤來定製故事,但是由用戶來填寫消息。
這隻有在您代表用戶發佈信息時纔有可能,這需要用戶通過publish_actions
permission授權您的應用程序。 和即使這樣:
請注意,Facebook的建議使用用戶啓動的共享模式。
看一看這個answer。
是的,Facebook的API只是改變了一個怪物;)真的很難跟上。 – 2012-06-12 03:26: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"/>
這是一個小小的破解。雖然舊分享按鈕已被替換爲「like」/「推薦」按鈕,如果您使用XFBML版本,您可以在其中添加註釋。更多信息她:
像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×630
就像@Ardee說你sharer.php從meta標籤的使用數據,該對話框API接受參數。 Facebook已經刪除了使用消息參數的功能,但是您可以使用在許多情況下可用的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域在該應用的接受域上市。
最簡單的方式在Facebook上分享的是:
https://www.facebook.com/sharer/sharer.php?u=xerosanyam.github.io"e=You_are_amazing
紅利:分享在Twitter上
簡單的方法是: https://twitter.com/intent/tweet?via=xerosanyam&text=You_are_amazing
[@ Ardee_Aram的(http://stackoverflow.com/a/5799060/3307368)答案仍然適用於人們想知道的問題。 – iamuros 2015-11-03 13:57:54