I am using the Facebook Graph API to publish on a user's wall. I give it these parameters:
message
name
description
picture
link
caption
It posts to the wall, but it is not treating it as a link. I know this because it does not open a new tab when the link is clicked, there is no share action link, and Twitter does not pick it up开发者_如何学编程 because I have it filtering my wall by links only.
I see the Facebook docs has two separate documentation pages for publish "Post" and "Link" objects.. but the links is posting to the same graph path so I am not sure how it is supported to work:
http://developers.facebook.com/docs/reference/api/post
http://developers.facebook.com/docs/reference/api/link
Anyone got this working?
Use the facebook API's available on codeplex.com and try this out,
Facebook.Rest.attachment_media_image image1 = new attachment_media_image();
image1.href = "";
image1.src = "";
Facebook.Rest.attachment a = new Facebook.Rest.attachment();
a.media = new List<Facebook.Rest.attachment_media> { image1 };
a.href = "";
a.name = "";
a.caption = "{*actor*}";
a.properties = null;
if(fbapi.Users.HasAppPermission(Enums.ExtendedPermissions.publish_stream))
fbapi.Stream.Publish(" Your message", a,
new List<action_link>()
{
new action_link()
{
text = "",
href = ""
}
},
null, 0);
What I do when using the open graph is this:
var uri = new Uri(
"https://graph.facebook.com/me/links?access_token=" + AccessToken);
var data =
message != null
? string.Format(
"link={0}&message={1}",
Uri.EscapeDataString(link),
Uri.EscapeDataString(message))
: string.Format("link={0}", Uri.EscapeDataString(link));
// (parameters other than link and message are grabbed from a website anyway)
WebClient client = new WebClient();
client.Headers["Content-type"] = "application/x-www-form-urlencoded";
client.Encoding = Encoding.UTF8;
client.UploadStringAsync(uri, "POST", data);
精彩评论