我正在用angular 8和dotnet core 3 Web API创建一个组件,以便在提交表单时拨打电话号码。我按照this tutorial实现了这一目标。下面是我的角度ts代码。
Phonecall() {
var params = { "phoneNumber": this.phoneNumber };
this.connection = Twilio.Device.connect(params); }
如本教程中所述,发出上述连接请求后,我通过网络挂钩收到了对我的控制器的发帖请求,但发帖请求中没有任何电话号码,因此出于测试目的,我对电话进行了硬编码数。在调用connect方法后我听到文本语音转换阅读我打算通话的phoneNumber]并且连接结束而没有启动呼叫,下面是控制器文件。
[Route("api/[controller]")] [ApiController] public class TwilioController : ControllerBase { [HttpGet("token")] public string GetToken() { const string accountSid = "xxxxxxxxxxxxxxxxx"; const string authToken = "xxxxxxxxxxxxxxxxxx"; const string appSid = "xxxxxxxxxxxxxxxxxxxxxxxxx"; var scopes = new HashSet<IScope> { new OutgoingClientScope(appSid) }; var capability = new ClientCapability(accountSid, authToken, scopes: scopes); return capability.ToJwt(); } [HttpPost("call")] [HttpPost] public string Connect([System.Web.Http.FromUri]string phoneNumber) { phoneNumber = "xxxxxxxxx"; string fromNumber = "xxxxxxxx"; var response = new VoiceResponse(); var dial = new Dial(callerId: fromNumber); if (phoneNumber != null) { dial.Number(phoneNumber); } else { dial.Client("support_agent"); } response.Append(dial); return response.ToString(); } }
下面是来自twilio调试器的日志。
Request Parameters: ApplicationSid "xxxxxx" ApiVersion "2010-04-01" phoneNumber "xxxxxx" Called "" Caller "client:Anonymous" CallStatus "ringing" To "" From "client:Anonymous" CallSid "xxxx" Direction "inbound" AccountSid "xxxx" Message Text: Msg "An attempt to retrieve content from https://b8d2ab8f8ec1.ngrok.io/api/Twilio/call returned the HTTP status code 415" msg "An attempt to retrieve content from https://b8d2ab8f8ec1.ngrok.io/api/Twilio/call returned the HTTP status code 415" sourceComponent "12000" ErrorCode "11200" httpResponse "415" LogLevel "ERROR" url "https://b8d2ab8f8ec1.ngrok.io/api/Twilio/call" Response Headers: Transfer-Encoding chunked X-Cache MISS from Twilio-Cache Server Microsoft-IIS/10.0 X-Cache-Lookup MISS from Twilio-Cache:3128 X-Twilio-WebhookAttempt 1 X-Twilio-WebhookRetriable false Date Tue, 09 Jun 2020 07:57:49 GMT X-Powered-By ASP.NET Content-Type application/problem+json; charset=utf-8 Response Body: Body No body.
任何人都可以告诉我我做错了什么,或者这是否是从浏览器拨打电话到电话号码的正确方法。提前谢谢。
我正在用angular 8和dotnet core 3 Web API创建一个组件,以便在提交表单时拨打电话号码。我按照本教程来实现。下面是我的角度ts代码。 ...
对此问题有解决方案吗?如果是这样,请分享,将对您有所帮助。