0

I want to post from my Facebook app to one of my pages using app_id and app_secret. It will help me to post directly without log in to Facebook. I'm able to post on my profile, but not on my page!

Here is my code:

        string url = string.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&client_secret={1}&grant_type={2}",
            app_id, app_secret, "client_credentials");

        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(access_token);

        client.Post("/my-page-FB-ID/feed", new { desctiption = description, picture = picture, link = link, caption = caption, type = type });
uh84
  • 61
  • 3
  • Get a page access token. https://developers.facebook.com/docs/facebook-login/access-tokens/ – CBroe Nov 10 '13 at 21:21
  • It asks me to login in order to get access token. Since I'm able to get app token, I want to be able to post on page wall. – uh84 Nov 10 '13 at 22:03
  • Found the solution here: http://stackoverflow.com/questions/10183625/extending-facebook-page-access-token/13477999#13477999 – uh84 Nov 11 '13 at 22:30

0 Answers0