Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to post to a facebook wall from silverlight application
    primarykey
    data
    text
    <p>I am using the facebook c#-sdk v5.0.50.0. Users of my silverlight application want an option to post information generated by my software onto their facebook wall.</p> <p>I think the SilverlightInBrowser sample in the SDK is the closest example of what I need in that it prompts the user for permission and also reads user information. I have got that part functioning OK (but do link to any fully working example you know of). </p> <p>The sample app uses</p> <pre><code>private string[] requestedFbPermissions = new[] { "user_about_me" }; </code></pre> <p>I presume I will have to change that to enable posting to the wall, to one of the permissions listed here - <a href="http://developers.facebook.com/docs/reference/api/permissions/" rel="nofollow">http://developers.facebook.com/docs/reference/api/permissions/</a> probably "publish_stream" would be my guess, which I can't test until I get the posting bit working.</p> <p>The next step is to write the post. I have not seen a silverlight version of this, so I have adapted slightly an answer to a non-silverlight question, as silverlight is slightly different (e.g. async callbacks). My code looks like so:</p> <pre><code> private void fbpost_Click2(object sender, RoutedEventArgs e) { var client = new FacebookClient(fb.AccessToken); dynamic parameters = new ExpandoObject(); parameters.message = "test posting - ignore"; parameters.link = "http://www.example.com/link"; parameters.picture = "http://www.example.com/picture.jpg"; parameters.name = "Test Post"; parameters.caption = "Test Post Caption"; parameters.description = "description here"; parameters.actions = new { name = "View on www.example.com", link = "http://www.example.com", }; parameters.privacy = new { value = "ALL_FRIENDS", }; parameters.targeting = new { countries = "US", regions = "6,53", locales = "6", }; client.PostCompleted += new EventHandler&lt;FacebookApiEventArgs&gt;(client_PostCompleted); client.PostAsync("me/feed", parameters); } void client_PostCompleted(object sender, FacebookApiEventArgs e) { dynamic result = e.GetResultData(); } </code></pre> <p>However what happens is I get an error calling <code>client.PostAsync("me/feed", parameters);</code></p> <p>Attempt by security transparent method 'SimpleJson.Reflection.CacheResolver.CreateDynamicMethod(System.String, System.Type, System.Type[], System.Type)' to access security critical method 'System.Reflection.Emit.DynamicMethod..ctor(System.String, System.Type, System.Type[], System.Type, Boolean)' failed.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload