【发布时间】:2019-01-08 08:50:19
【问题描述】:
我正在使用芭蕾舞演员创建客户注册休息服务,与此相关的用例是当客户成功注册时,我需要向客户发送短信。当我使用芭蕾舞演员中的 Twilio 连接器发送短信时,我得到以下错误。
404 Not Found-:The requested resource /2010-04-01/Accounts//SMS/
Messages.json was not found.
下面显示了与 Twilio 集成相关的代码,
import wso2/twilio;
twilio:Client twilioClient = new({
accountSId: config:getAsString(TWILIO_ACCOUNT_SID),
authToken: config:getAsString(TWILIO_AUTH_TOKEN)
});
我也在 ballerina.conf 文件中包含了 Twilio-Sid 和 Auth Token。下面显示了我编写的通过 Twilio-connector 发送短信的函数
function sendSmsToCustomers(string mobile) returns boolean {
boolean isSuccess= false;
string toMobile = mobile;
string messageBody = config:getAsString(TWILIO_MESSAGE);
string fromMobile = config:getAsString(TWILIO_FROM_MOBILE);
string message = messageBody;
var response = twilioClient->sendSms(fromMobile, toMobile, message);
if (response is twilio:SmsResponse) {
if (response.sid != EMPTY_STRING) {
log:printDebug("Twilio Connector -> SMS successfully sent to " + toMobile);
return true;
}
} else {
log:printDebug("Twilio Connector -> SMS failed sent to " + toMobile);
log:printError(<string>response.detail().message);
}
return isSuccess;
}
预期的输出应该是向提供的手机号码(toMobile)发送一条短信
【问题讨论】:
标签: twilio-api ballerina