如何修复芭蕾舞女演员Twilio连接器中的404 "The requested resource /2010-04-01/Accounts//SMS/Messages.json"未找到错误



我正在使用芭蕾舞演员创建客户注册休息服务,与此相关的用例是当客户成功注册时,我需要向客户发送短信。当我在芭蕾舞演员中使用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连接器发送短信的功能

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;
}

预期的输出应该是向提供的手机号码发送短信(到手机)

这里的问题是TWILIO_ACCOUNT_SID不是从ballerina.conf文件中读取的。ballerina.conf 文件应具有如下配置属性,以便与您的代码匹配。

TWILIO_ACCOUNT_SID="your_account_sid"
TWILIO_AUTH_TOKEN="your_auth_token"
TWILIO_MESSAGE="your_message"
TWILIO_FROM_MOBILE="your_from_mobile_number"

我遇到了类似的问题。我在Twilio/Rest/Client.php中发现了什么构造函数需要用户名、密码和其他详细信息。

公共函数 __construct(字符串 $username = null,字符串 $password = null,字符串 $accountSid = null,字符串 $region = null,HttpClient $httpClient = null,数组 $environment = null)

但在用于库加载的 Twilio 中.php它试图通过传递 SID 和 TOKEN 来创建客户端对象。

因此,最有可能的是,共享的库代码不正确或版本不同

最新更新