简体   繁体   中英

Connect facebook Webhook with asp.net application

I am trying to connect facebook webhook to asp.net application but I am getting 'The URL couldn't be validated. Response does not match challenge' error.

However I can see the response is correct from my .net application but in facebook it shows with prefix '\\\' Here is the error I am getting

I am sending response to callback url using below code :

        var challenge = Convert.ToString(Request.QueryString["hub.challenge"]);

        var verifyToken = Request.QueryString["hub.verify_token"];


        if (verifyToken == "abcxyz123")
        {

            Response.Write(challenge);
        }

Any help is greatly apprecialted. Thanks

    public HttpResponseMessage Webhook()
    {
        var response = new HttpResponseMessage(HttpStatusCode.OK)
        {
            Content = new StringContent(System.Web.HttpContext.Current.Request.QueryString["hub.challenge"])
        };
        response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/plain");

        return response;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM