简体   繁体   中英

Facebook integration with azure function

I developed an Azure function and its running fine on Azure.

But I am finding it difficult to modify that function to set it up as a Facebook web hook so that my 'get()' and 'post()' methods get called with the required Facebook parameters.

Any help appreciated.

Here is example for webhook from facebook

namespace Facebook.Function
{
    public class AddLeadWebhook
    {    
        [FunctionName("AddLeadWebhook")]
        public async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]
            HttpRequest req,
            ILogger log)
        {
            this.log = log;
            log.LogInformation("C# HTTP trigger function processed a request.");

            //Facebook challenge (facebook test webhook)
            if (!string.IsNullOrEmpty(req.Query["hub.challenge"]))
            {
                log.LogInformation("Facebook challenged");
                return new OkObjectResult(req.Query["hub.challenge"].FirstOrDefault());
            }

            TODO process request
            ...

            return new OkResult();
        }
    }
}

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