Facebook error

Posted on 2014-08-09
Last Modified: 2014-11-29
Hi Guys

I have th below code and i am trying to post to a fan page on facebook but it gives me an error of("invalidate parameters")

Please can you assist?

            string app_id = "xxxxxxx";
            string app_secret = "xxxxxxxxxxxxxxxxxxxxx";
            string scope = "publish_stream,manage_pages";

            if (Request["code"] == null)
                Response.Redirect(string.Format("{0}&redirect_uri={1}&scope={2}", app_id, Request.Url.AbsoluteUri, scope));
                Dictionary<string, string> tokens = new Dictionary<string, string>();

                string url = string.Format("{0}&redirect_uri={1}&scope={2}&code={3}&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('&'))
                        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);

                var parameters = new Dictionary<string, object>();

                parameters["picture"] = "";
                //parameters["link"] = "";
                //parameters["name"] = "[name] Facebook name...";
                //parameters["caption"] = " Facebook caption";
                //parameters["description"] = "[description] Facebook description...";
                parameters["message"] = "[message] Facebook message...";

                client.Post("/me/feed", parameters);

        catch (FacebookOAuthException ex)
            //handle oauth exception
        catch (FacebookApiException ex)
            //handle facebook exception

Open in new window

Question by:JCWEBHOST

    Accepted Solution

    Please let me know what version of FB  API you are using and also version of PHP installed on you server where you are running this code. I think it maybe a version issue. I came across something like this before and it turned out to be the fact that the version of API we used for FB was not compatible with the PHP version we had on the server.

    Author Closing Comment

    thanks i quit trying to fix it

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now