Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
My Code for App

C#
private void CheckAuthorization()
        {
            string app_id = "************";
            string app_secret = "************";
            string scope = "publish_stream,manage_pages";
 
            if (Request["code"] == null)
            {
                Response.Redirect(string.Format(
                    "https://graph.facebook.com/oauth/authorize?client_id={0}&redirect_uri={1}&scope={2}",
                    app_id, Request.Url.AbsoluteUri, scope));
            }
            else
            {
                Dictionary<string,> tokens = new Dictionary<string,>();
 
                string url = string.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&redirect_uri={1}&scope={2}&code={3}&client_secret={4}",
                    app_id, Request.Url.AbsoluteUri, scope, Request["code"].ToString(), app_secret);
 
                HttpWebRequest request = 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('&'))
                    {
                        //meh.aspx?token1=steve&token2=jake&...
                        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(token);
 
             //   client.Post("/me/feed", new { message = "www.appibook.com tutorial" });  //ITS WRITE ON USER WALL SUCESSFULLY

                dynamic parameters = new ExpandoObject();
                parameters.message = "Hello This Is My First Post To Facebook";
          //      parameters.link = "http://www.google.com";
          //      parameters.picture = "http://www.appibook.com/Logo.gif";
          //      parameters.name = "Hello Users We welcome you all";
          //      parameters.caption = "Posted By Ashish";



               client.Post("/1613936732155015/feed", parameters);
//but not post on facebook page I also admin of facebook page


            }
        }
Posted
Updated 26-Mar-15 2:19am
v2
Comments
kashifjaat 26-Mar-15 1:38am    
(OAuthException - #200) (#200) Permissions error
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Facebook.FacebookOAuthException: (OAuthException - #200) (#200) Permissions error

Source Error:


Line 73:
Line 74:
Line 75: client.Post("/1613936732155015/feed", parameters);
Line 76:
Line 77:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900