Reputation: 55248
I am using Facebook C# SDK 6.0.20 and posting to facebook (Server Side Flow) like this.
dynamic parameters = new ExpandoObject();
parameters.message = message;
parameters.description = description;
parameters.link = url;
parameters.name = url;
parameters.picture = smallImage;
parameters.caption = "www.mysite.com";
parameters.properties = new
{
text = joinPrompter,
href = url
};
parameters.actions = new
{
name = joinPrompter,
link = url
};
var api = new FacebookClient
{
AccessToken = accessToken,
AppId = ClientID,
AppSecret = ClientSecret
};
result = api.Post("me/feed", parameters);
All is well except the properties I am passing. It gets displayed in the post at the end as
text: Join now!
href: http://www.mysite.com
What could be wrong with my post to me/feeds?
Upvotes: 2
Views: 719
Reputation: 25938
Actually properties should be JSON encoded prior to publishing.
JsonArray jsonArray = new JsonArray();
jsonArray.Add(new {
text = joinPrompter,
href = url
});
parameters.properties = jsonArray.ToString();
This is sample using SimpleJson which is internally used in facebook-c#-sdk.
Or you can simply use something like:
parameters.properties = '[{"text":"Some text", "href":"http://example.com"}]';
Update:
Seems that you may use IList<object>
and it should be encoded automatically by Facebook C# SDK:
IList<object> properties = new IList<object>();
properties.Add(new {
text = joinPrompter,
href = url
});
parameters.properties = properties;
Upvotes: 2
Reputation: 55248
The problem was not with the wonderful Facebook C# SDK. The problem was with the way I used it. properties
should be used like this
parameters.properties = new {
URL = new
{
text = joinPrompter,
href = url
}
};
Upvotes: 1