是的,這是可能的。您可以使用Graph Api方法/profile_id/feed
。該方法接收參數消息,圖片,鏈接,名稱,標題,說明,來源,地點和標籤。 facebook以「漂亮的總結和縮略圖」組織參數。
你可以在出版科的詳細信息中的鏈接http://developers.facebook.com/docs/reference/api/
在C#:
public static bool Share(string oauth_token, string message, string name, string link, string picture)
{
try
{
string url =
"https://graph.facebook.com/me/feed" +
"?access_token=" + oauth_token;
StringBuilder post = new StringBuilder();
post.AppendFormat("message={0}", HttpUtility.UrlEncode(message));
post.AppendFormat("&name={0}", HttpUtility.UrlEncode(name));
post.AppendFormat("&link={0}", HttpUtility.UrlEncode(link));
post.AppendFormat("&picture={0}", HttpUtility.UrlEncode(picture));
string result = Post(url, post.ToString());
}
catch (Exception)
{
return false;
}
return true;
}
private static string Post(string url, string post)
{
WebRequest webRequest = WebRequest.Create(url);
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Method = "POST";
byte[] bytes = Encoding.ASCII.GetBytes(post);
webRequest.ContentLength = bytes.Length;
Stream stream = webRequest.GetRequestStream();
stream.Write(bytes, 0, bytes.Length);
stream.Close();
WebResponse webResponse = webRequest.GetResponse();
StreamReader streamReader = new StreamReader(webResponse.GetResponseStream());
return streamReader.ReadToEnd();
}
UPDATE:
的Open Graph協議的meta標籤:http://developers.facebook.com/docs/opengraphprotocol/
而Facebook會自動抓取描述 - 您不必親自獲取並通過它在'description'參數中? – Eric
嗯,它沒有很好的記錄,但有時當我發送一個鏈接Facebook做的工作,有時不(我認爲它只適用於該網站有開放圖協議元標籤實施,但我不知道這一點)。爲了完全控制輸出,您必須發送所有內容。因爲我在自己的網站上做這件事,所以我需要在變量中使用所有字段,所以發送所有內容都不是問題。 – lolol