I'm using Facebook C# API and I want to create a custom "Like" action, allowing the user to like objects outside of Facebook.
The user will be allowed to "Like" a custom object, like an Apple or a Book, and the app has to post this information in the user timeline.
I've tried
dynamic res = fb.Post("me/og.likes", new
{
message = "My first like post using Facebook SDK for .NET"
});
But this gives me the following FacebookApiException exception
(Exception - #1611072) The action you're trying to publish is invalid because it does not specify any reference objects. At least one of the following properties must be specified: object.
But if I try
dynamic res = fb.Post("me/og.likes", new
{
object="http://samples.ogp.me/226075010839791"
});
it doesn't even compile, since object is a reserved word on C#.
What should I do? Is it possible?
Try escape using @:
dynamic res = fb.Post("me/og.likes", new
{
@object="http://samples.ogp.me/226075010839791"
});
EDIT: For other special characters you should be able to use a dictionary instead of a anonymous typed object:
var postInfo = new Dictionary<string, object>();
postInfo.Add("fb:explicitly_shared", "your data");
dynamic res = fb.Post("me/og.likes", postInfo);