如何调试/设置本地环境来测试twilio callbackurl

时间:2022-12-16 00:24:29

I set up a test account for twilio and my method in C# is sending sms correctly. But the status in response object (SMSMessage) is queued. I understand that if I pass a call back url, then twilio will update the status when it does get updated. My question is, how do I test it? I searched the internet and found that if I have thread.sleep(1000) and then hold on to the sid returned in response and make a call to the url https://api.twilio.com/2010-04-01/Accounts/AC123/SMS/Messages/08jdsxxxxxx.json where 08jdsxxxxxx is the sid returned then I could peek into the response. But this is giving me 401 error.

我为twilio设置了一个测试帐户,我在C#中的方法正确地发送了sms。但响应对象(SMSMessage)中的状态排队。我知道如果我传回一个回调网址,那么twilio会在更新时更新状态。我的问题是,我该如何测试?我搜索了互联网,发现如果我有thread.sleep(1000),然后坚持回复的sid并打电话给网址https://api.twilio.com/2010-04-01/Accounts /AC123/SMS/Messages/08jdsxxxxxx.json其中08jdsxxxxxx是sid返回然后我可以查看响应。但这给了我401错误。

How to debug the message status changes? From a developer perspective, how to set up a local environment for callbackurl?

如何调试消息状态的变化?从开发人员的角度来看,如何为callbackurl设置本地环境?

I searched the internet but couldn't find my info, their documentation does provide more info either.

我搜索了互联网,但找不到我的信息,他们的文档确实提供了更多的信息。

Many thanks.

1 个解决方案

#1


Twilio developer evangelist here.

Twilio开发者传道者在这里。

There are several ways you can do that, but because you said you're suing C#, there are two way I normally do it that give me all the flexibility I need. If I'm still inspecting callbacks and want to be using debugging, I use ngrok, which is as free application that tunnels requests from outside into your network.

有几种方法可以做到这一点,但因为你说你在起诉C#,我通常会采用两种方式来提供我所需要的所有灵活性。如果我还在检查回调并希望使用调试,我使用ngrok,这是一个免费的应用程序,可以将来自外部的请求传输到您的网络中。

My colleague Devin wrote an article explaining how to do this very thing. Check it out and I'm sure you will be able to do exactly what you're trying to.

我的同事德文写了一篇文章解释如何做到这一点。检查出来,我相信你将能够做到你正在努力的目标。

The other option would be to create a free Azure account, and deploy your application there. That way you will can test live webhooks. Azure also has provisions that let you set breakpoint in your code for debugging, but ngrok makes it much easier, and you won't need to publish your code every single time.

另一种选择是创建一个免费的Azure帐户,并在那里部署您的应用程序。这样你就可以测试实时webhook。 Azure还有一些条款允许您在代码中设置断点以进行调试,但是ngrok使得它变得更加容易,并且您不需要每次都发布代码。

#1


Twilio developer evangelist here.

Twilio开发者传道者在这里。

There are several ways you can do that, but because you said you're suing C#, there are two way I normally do it that give me all the flexibility I need. If I'm still inspecting callbacks and want to be using debugging, I use ngrok, which is as free application that tunnels requests from outside into your network.

有几种方法可以做到这一点,但因为你说你在起诉C#,我通常会采用两种方式来提供我所需要的所有灵活性。如果我还在检查回调并希望使用调试,我使用ngrok,这是一个免费的应用程序,可以将来自外部的请求传输到您的网络中。

My colleague Devin wrote an article explaining how to do this very thing. Check it out and I'm sure you will be able to do exactly what you're trying to.

我的同事德文写了一篇文章解释如何做到这一点。检查出来,我相信你将能够做到你正在努力的目标。

The other option would be to create a free Azure account, and deploy your application there. That way you will can test live webhooks. Azure also has provisions that let you set breakpoint in your code for debugging, but ngrok makes it much easier, and you won't need to publish your code every single time.

另一种选择是创建一个免费的Azure帐户,并在那里部署您的应用程序。这样你就可以测试实时webhook。 Azure还有一些条款允许您在代码中设置断点以进行调试,但是ngrok使得它变得更加容易,并且您不需要每次都发布代码。