0

我想使用 app_id 和 app_secret 从我的 Facebook 应用发布到我的页面之一。它将帮助我在不登录 Facebook 的情况下直接发帖。我可以在我的个人资料上发帖,但不能在我的页面上发帖!

这是我的代码:

        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 });
4

0 回答 0