Share using Facebook C# SDK
I am new to the Facebook C# SDK. I hope you are able to give me some guidance.
I would like to be able Share some content on my site on Facebook.
Here's what I would like to do:
On my site, when the user clicks 'Share on Facebook', I would like to send a few pieces of information -- A thumbnail image, A ti开发者_StackOverflowtle row, and some content to their facebook wall.
I have seen other sites do this seemlessly. I am hoping this SDK can do it to.
I am using Facebook 4.2.1 SDK.
Thanks in advance for your help. Steve
You can find an example on how to do that and many other things here: http://facebooksdk.codeplex.com/wikipage?title=Code%20Examples&referringTitle=Documentation
Here is the code:
var client = new FacebookClient("my_access_token");
dynamic parameters = new ExpandoObject();
parameters.message = "Check out this funny article";
parameters.link = "http://www.example.com/article.html";
parameters.picture = "http://www.example.com/article-thumbnail.jpg";
parameters.name = "Article Title";
parameters.caption = "Caption for the link";
parameters.description = "Longer description of the link";
parameters.actions = new {
name = "View on Zombo",
link = "http://www.zombo.com",
};
parameters.privacy = new {
value = "ALL_FRIENDS",
};
parameters.targeting = new {
countries = "US",
regions = "6,53",
locales = "6",
};
dynamic result = client.Post("me/feed", parameters);
Note: This is using Version 5 of the SDK. FacebookClient was named FacebookApp in Version 4.
Just and update, link to project URL:
https://github.com/facebook-csharp-sdk/facebook-csharp-sdk
精彩评论