0

我已经用 twilio 验证了我自己的手机号码,但该号码来自马来西亚的服务提供商。我做了代码来发送短信,但我无法在我的号码上收到它。我需要美国或加拿大号码,还是必须从 twilio 购买号码才能测试代码。以下是代码:

WebForm1.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication4.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h4>To Number: </h4>
        <asp:TextBox ID="ToNumber" TextMode="password" runat="server"></asp:TextBox>
        <h4>SMS Message</h4>
        <asp:TextBox ID="Message" runat="server"></asp:TextBox>
        <br/>
        <br/>
        <br/>
        <asp:Button ID="SendMessage" OnClick="SendMessage_OnClick" runat="server" Text="Send Message" />

    </div>
    </form>
</body>
</html>

WebForm1.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using Twilio;
namespace WebApplication4
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)


   {

    }

    protected void SendMessage_OnClick(object sender, EventArgs e)
{
        string ACCOUNT_SID = ConfigurationManager.AppSettings["ACCOUNT_SID"];
        string AUTH_TOKEN = ConfigurationManager.AppSettings["AUTH_TOKEN"];

        TwilioRestClient client= new TwilioRestClient(ACCOUNT_SID, ACCOUNT_SID);
        client.SendSmsMessage("(862) 373-1913", ToNumber.Text, Message.Text);

}
}

}

我已经用 Visual Studio 2012 检查了代码是否正常,但似乎仍然无法接收短信。我应该怎么办?

4

2 回答 2

0

利用:

var result = client.SendSmsMessage("(862) 373-1913", ToNumber.Text, Message.Text);

看看result。如果大多数字段为空,请查看result.RestException. 一个常见的问题是身份验证。

于 2014-06-14T20:27:52.277 回答
0

twilio 不支持某些数字,例如以 94,87 开头。通过它与沃达丰公司号码一起工作。请尝试一下。

于 2013-03-13T04:27:26.300 回答