Click here to Skip to main content
15,881,881 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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, string> tokens = new Dictionary<string, 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, "http://localhost:62057/FacebookShareLink/Default.aspx", scope, Request["code"].ToString(), app_secret);
          //"http://localhost:49252/WebSite4/Default.aspx"
          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('&'))
              {
                  //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);

          dynamic parameters = new ExpandoObject();
          parameters.message = Session["postmsg"].ToString();
          parameters.link = "http://www.filmatest.somee.com";
          parameters.picture = "http://www.filmatest.somee.com/Image_Bg/head.gif";
          parameters.name = "Article Title";
          parameters.caption = "Caption for the link";
          //parameters.published = false;
          parameters.scheduled_publish_time = Facebook.DateTimeConvertor.ToUnixTime(DateTime.Now.AddMinutes(15)); ;

          //parameters.scheduled_publish_time = GetUnixTimestamp(DateTime.Now.AddMinutes(20));


          client.Post("/Look4Movie/feed", parameters);
          Session.Clear();
          Session.Abandon();

          Response.Redirect("http://localhost:62057/FacebookShareLink/Default.aspx");
      }


this is how i try to post on facebook fanpage when i take off parameters.scheduled_publish_time this work fine but when i try to use it i get this error
(OAuthException - #100) (#100) You cannot specify a scheduled publish time on a published post c#
can some one help me plss?
sorry for my bad english
Posted

1 solution

Add this into your parameters
C#
parameters.published= "0";


Worked for me.
Let me know if it worked for you as well.
 
Share this answer
 

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