按字母排序的发件人ID不是由Twilio发送短信

时间:2017-08-16 12:55:39

标签: twilio

我已在salesforce中设置Twilio来发送短信。 Twilio配置完美。

我尝试发送短信的号码也位于字母数字发送者ID列表的可支持国家/地区列表中。 国家:黎巴嫩。

当我输入From号码时:喜欢+1 45 ********。然后我就可以发送SM了。但是,当我将From号码设为" CompanyName"时,则不发送短信。

错误。

  

来自电话号码"公司名称"不是有效的,支持短信的入站电话号码或您帐户的短代码。

请注意:我的帐户已启用字母数字发件人ID。我的帐户也升级了。

我的代码在下面;

 global Static String sendOTP(string PhoneNo){
    Integer rand = Math.round(Math.random()*100000);
    string VerificationCode = string.valueOf(rand);
    String smsBody='Your Verification code is : '+VerificationCode +'. Please don\'t reply.';
    final String  fromNumber = '+14*******';  
    //final String  fromNumber = 'Comapany'; //Not working
    String account = '********';     // Account SID on home tab
    String token   = '*****';  //AUTH Token on home tab
    TwilioRestClient client = new TwilioRestClient(account, token);
    if(PhoneNo != null)

    {
         Map<String,String> params = new Map<String,String> {
        'To'   => PhoneNo, 
        'From' => fromNumber,
        'Body' => smsBody
         };
         try{
         TwilioSMS sms = client.getAccount().getSMSMessages().create(params);
         system.debug('******');
         return VerificationCode;
         }
         catch(Exception e )
         {
            system.debug('@@@@'+e);
          return 'false';
         }   
    }
    return 'false';
}

请在此处说明错误。

1 个答案:

答案 0 :(得分:0)

Twilio开发者传道者在这里。

问题是您使用的是已弃用的SMS/Messages资源,该资源不支持通过字母数字ID发送。您想改用Messages resource

谢天谢地,修复很简单,只需更改

即可
TwilioSMS sms = client.getAccount().getSMSMessages().create(params);

TwilioSMS sms = client.getAccount().getMessages().create(params);

getSMSMessages的差异由getMessages替换。

如果有帮助,请告诉我。

相关问题