Facebook added a product called Webhooks to subscribe to the changes and receive updates in real-time without calling the API. This blog is about configuring the webhook product in Facebook and integrating it in the ASP.NET Application.
Webhooks basically work with the protocol named as WebSub, which contain three main components,
- Publisher
- Subscriber
- Hub
In the case of Facebook Webhook, the user who wants to get notified for the newest post updated on the page is the subscriber. Publishing and hub part will handled by Facebook itself.
Configure the end-point in ASP.NET Web API
Create the ASP.NET application. Create get/ post-end-points for Facebook like below,
- public class WebHookController : ApiController
- {
- public class WebhooksController : ApiController
- {
- #region Get Request
- [HttpGet]
- public HttpResponseMessage Get()
- {
- 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;
- }
- #endregion Get Request
- #region Post Request
- [HttpPost]
- public HttpResponseMessage Post(Feed data)
- {
- try
- {
- //You got the data do whatever you want here!!!Happy programming!!
- return new HttpResponseMessage(HttpStatusCode.OK);
- }
- catch (Exception ex)
- {
- return new HttpResponseMessage(HttpStatusCode.BadGateway);
- }
- }
- #endregion
- }
- }





Nihat FidePosted May 28, 2023, 11:03 PM
Hi, It does not request to the endpoint with The api v13. Is there ant solution did you encounter like that problem?
Nihat FidePosted May 28, 2023, 11:03 PM
Hi, It does not request to the endpoint with The api v13. Is there ant solution did you encounter like that problem?