Sms Can';无法使用Twilio Trail帐户使用C发送短信#

Sms Can';无法使用Twilio Trail帐户使用C发送短信#,sms,twilio,twilio-api,Sms,Twilio,Twilio Api,我只是想用Twilio发送交易短信。我已经尝试了Twilio文档中提供的完全相同的代码 static void Main(string[] args) { try { // Find your Account Sid and Token at twilio.com/console const string accountSid = "AC5270abb139629daeb8f3c205ec632155";

我只是想用Twilio发送交易短信。我已经尝试了Twilio文档中提供的完全相同的代码

 static void Main(string[] args)
    {
        try
        {
            // Find your Account Sid and Token at twilio.com/console
            const string accountSid = "AC5270abb139629daeb8f3c205ec632155";
            const string authToken = "XXXXXXXXXXXXXX";

            TwilioClient.Init(accountSid, authToken);

            var message = MessageResource.Create(
                from: new Twilio.Types.PhoneNumber("+15017122661"),
                body: "Body",
                to: new Twilio.Types.PhoneNumber("MyNumber")
            );

            Console.WriteLine(message.Sid);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }
在这个来自Twilio控制台的authToken副本中,TO号码是我的号码,用于在Twilio上注册。我还验证了Twilio控制台中已验证的呼叫者ID段中的号码。 从最初的数字开始,我使用的是由Twilio控制台生成的数字。这个数字属于美国,但它不起作用。看完这个 我使用了Twilio提供的确切代码,只是将更改作为authToken和数字。但是,它仍然不起作用


我不知道为什么它不起作用。您不能从一个国家向另一个国家发送消息吗?

因为我想通过短信发送代码来验证手机号码。因此,实现我正在使用的目标 Twilio验证API,其中代码由Twilio生成并由他自己验证

这解决了我的问题

发送短信息:

  var client = new HttpClient();
  var requestContent = new FormUrlEncodedContent(new[] {
  new KeyValuePair<string,string>("via", "sms"),
  new KeyValuePair<string,string>("phone_number", "Moblienumber"),
  new KeyValuePair<string,string>("country_code", "CountryCode"),
});

            // https://api.authy.com/protected/$AUTHY_API_FORMAT/phones/verification/start?via=$VIA&country_code=$USER_COUNTRY&phone_number=$USER_PHONE
            HttpResponseMessage response = await client.PostAsync(
              "https://api.authy.com/protected/json/phones/verification/start?api_key=" + "Your Key",
              requestContent);

            // Get the response content.
            HttpContent responseContent = response.Content;

            // Get the stream of the content.
            using (var reader = new StreamReader(await responseContent.ReadAsStreamAsync()))
            {
                // Write the output.
                Console.WriteLine(await reader.ReadToEndAsync());
            }
            return Ok();

如果消息已排队,您将收到
message.sid
,并且它将被传递,否则您是否会收到任何异常?Twilio错误代码:30008,来自Twilio控制台@chennoto confirm,您是否使用生产凭据发送消息(不使用测试凭据)?您是否检查了文档并检查了所有可能的解决方案?如果您可能无法发送到不同的国家,请检查您的电子邮件地址。
// Create client
        var client = new HttpClient();

        // Add authentication header
        client.DefaultRequestHeaders.Add("X-Authy-API-Key", "Your Key");

        // https://api.authy.com/protected/$AUTHY_API_FORMAT/phones/verification/check?phone_number=$USER_PHONE&country_code=$USER_COUNTRY&verification_code=$VERIFY_CODE
        HttpResponseMessage response = await client.GetAsync(
          "https://api.authy.com/protected/json/phones/verification/check?phone_number=phone_number&country_code=country_code&verification_code=CodeReceivedbySMS ");

        // Get the response content.
        HttpContent responseContent = response.Content;

        // Get the stream of the content.
        using (var reader = new StreamReader(await responseContent.ReadAsStreamAsync()))
        {
            // Write the output.
            Console.WriteLine(await reader.ReadToEndAsync());
        }
        return Ok();