Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I hope this post will be helpfull for lots of people, i try to be simple and clear :</p> <p>1-Create your facebook developper account, and to test your code in your computern (<code>localhost</code>), set your localhost adress in the field "website authentication with facebook authentication". For me it will be <code>http://localhost:2551/Default.aspx</code> for example because i test in the Defaut.aspx of my wweb application. You 'll change this adress when you'll deploy on your website (for me i ll change with <a href="http://www.mywebsiteurl.com/Default.aspx">http://www.mywebsiteurl.com/Default.aspx</a> just before deploy the code on my website).</p> <p>2- With your facebook user account, create your fan page.</p> <p>3-When you created your fan page , go to your fan page see the URL to obtain your PAGE_ID For example mine is <a href="http://www.facebook.com/pages/toto/446533181408238?ref=ts&amp;fref=ts">http://www.facebook.com/pages/toto/446533181408238?ref=ts&amp;fref=ts</a> so my PAGE_ID is 446533181408238</p> <p>3- It's almost finished, just a little explanation : because i created the fan page , i m administrator of the fan page and i must ask the authoraization to facebook to post since my developper account so i must get the autorisation for 2 actions : publish_stream and manage_pages.</p> <p>Let's go for coding :</p> <pre><code> private void Do() { string app_id = "157873644371675"; string app_secret = "c27a10c347af4280720fa3d76c9ae08c"; string scope = "publish_stream,manage_pages"; if (Request["code"] == null) { Response.Redirect(string.Format( "https://graph.facebook.com/oauth/authorize?client_id={0}&amp;redirect_uri={1}&amp;scope={2}", app_id, Request.Url.AbsoluteUri, scope)); } else { Dictionary&lt;string, string&gt; tokens = new Dictionary&lt;string, string&gt;(); string url = string.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&amp;redirect_uri={1}&amp;scope={2}&amp;code={3}&amp;client_secret={4}", app_id, Request.Url.AbsoluteUri, scope, Request["code"].ToString(), app_secret); HttpWebRequest request = System.Net.WebRequest.Create(url) as HttpWebRequest; using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { StreamReader reader = new StreamReader(response.GetResponseStream()); string vals = reader.ReadToEnd(); foreach (string token in vals.Split('&amp;')) { //meh.aspx?token1=steve&amp;token2=jake&amp;... tokens.Add(token.Substring(0, token.IndexOf("=")), token.Substring(token.IndexOf("=") + 1, token.Length - token.IndexOf("=") - 1)); } } string access_token = tokens["access_token"]; var client = new FacebookClient(access_token); dynamic parameters = new ExpandoObject(); parameters.message = "Check out this funny article"; parameters.link = "http://www.natiska.com/article.html"; parameters.picture = "http://www.natiska.com/dav.png"; parameters.name = "Article Title"; parameters.caption = "Caption for the link"; //446533181408238 is my fan page client.Post("/446533181408238/feed", parameters); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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