Pergunta

I have set up Real Time Update for Facebook (user and page) via the app's Dashboard and received an success message from Facebook. But I don't get any messages from Facebook after that. If a user makes a comment on a post on a page that is using the app, noting is sent from Facebook even though Facebook should.

I have read everything on Facebook developer pages regarding real time update and searched the internet using google, but I can't seem to understand why it isn't working.

Does someone know what might be wrong? Does someone know why I don't receive any updates?

Regards, Jonas

Here's the code I use to handle the post from Facebook. However, there are no POST from Facebook logged in IIS except for the one used to set up and start the subscription.

protected void Page_Load(object sender, EventArgs e)
    {
        String verify_token_created_in_app = "1234";
        logger.Error("Nu borde det synas");

        String hub_mode = Request.QueryString["hub.mode"];
        String hub_challenge = Request.QueryString["hub.challenge"];
        String hub_verify_token = Request.QueryString["hub.verify_token"];
        int customerId = Convert.ToInt32(Request.QueryString["c"]);

        if (hub_mode == null)
        {
            hub_mode = "";
        }
        if (hub_challenge == null)
        {
            hub_challenge = "";
        }
        if (hub_verify_token == null)
        {
            hub_verify_token = "";
        }
        if (hub_verify_token.Equals(verify_token_created_in_app))
        {
            Response.Write(hub_challenge);
        }

        if (hub_mode == "" || hub_challenge == "" || hub_verify_token == "")
        {
            HttpCookie sessionCookie = new HttpCookie("facilSession");
            HttpContext.Current.Response.Cookies.Add(sessionCookie);
            Utilities.customerId = customerId;
            spreadClass spread = new spreadClass();
            var client = new FacebookClient(spread.mfbAccessToken);
            string jsonString = "";

            realTimeUpdateParser = new RealTimeUpdateParser();
            List<RealTimeUpdateParser> realTimeUpdateParserList = new List<RealTimeUpdateParser>();

            try
            {
                logger.Error("Inne i metoden som ska läsa JSON från Facebook");
                // VerifyPostSubscription will throw exception if verification fails.
                dynamic result = client.VerifyPostSubscription(
                    Request.Headers["X-Hub-Signature"],
                    new StreamReader(Request.InputStream).ReadToEnd());

                // result is a json object that was sent by Facebook
                // for now just call ToString() so it returns the json string
                jsonString = result.ToString();
                logger.Error("jsonString: " + jsonString);

                // Process the result
                // for this demo we will just add it to the list

            }
            catch (Exception ex)
            {
                logger.Error("Error: " + ex.Message);
            }

            realTimeUpdateParserList = JsonConvert.DeserializeObject<List<RealTimeUpdateParser>>(jsonString);


            ConnectToFacebookAPI connectToFacebookAPI = new ConnectToFacebookAPI(client, spread);
            connectToFacebookAPI.HandleRealTimeUpdateFromFacebook(realTimeUpdateParserList, customerId);


        }
    }
Foi útil?

Solução

The problem wasn't really a problem. I didn't get any updates from Facebook because they took many hours to start sending the updates related to the subscription.

Now it's working just fine!

Thanks anyway!

Regards, Jonas

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top