我正在嘗試創建一個簡單的webhook來接收Nexmo SMS服務的收貨收據。他們網站上唯一的文檔是這樣的。如何在ASP.NET MVC中創建webhook?
During account set-up, you will be asked to supply Nexmo a CallBack URL for Delivery Receipt to which we will send a delivery receipt for each of your SMS submissions. This will confirm whether your message reached the recipient's handset. The request parameters are sent via a GET (default) to your Callback URL and Nexmo will be expecting response 200 OK response, or it will keep retrying until the Delivery Receipt expires (up to 72 hours).
我一直在尋找各種方法來做到這一點,到目前爲止,我有一個例子,我在網上找到了這個方法,雖然我不知道這是否是正確的。無論如何,這是在ASP.NET和端口6563上運行,所以這是我應該聽的端口?我下載了一個名爲ngrok的應用程序,它應該將我的本地Web服務器暴露給互聯網,所以我運行該應用程序並指示它監聽端口6563,但沒有運氣。我一直在擺弄它試圖找到發佈到這個功能。
[HttpPost]
public ActionResult CallbackURL()
{
System.IO.StreamReader reader = new System.IO.StreamReader(HttpContext.Request.InputStream);
string rawSendGridJSON = reader.ReadToEnd();
return new HttpStatusCodeResult(200);
}
通常我可以直接調用函數只是通過訪問http://localhost:6563/Home/Index/CallbackURL
所以,我插入方法簽名斷點返回看法,但它只會被調用,如果我刪除[HttpPost]從它。我應該嘗試下一步嗎?
請看看這裏的更多詳細信息: https://neelbhatt40.wordpress.com/2015/10/14/ webhooks-in-asp-net-a-visual-studio-extension/ – Neel 2015-10-16 05:09:13