我试过用Twilio传递信息
但我得到了认证错误:
{"code":20003,"message":"Authentication Error - No credentials provided","more_info":"https:\/\/www.twilio.com\/docs\/errors\/20003","status":401}
Account SID
和Auth Token
根据需要更改代码:
// Create environment variables (named below) with your Twilio credentials
client := TTwilioClient.Create(
GetEnvironmentVariable('*************************a271d22b1'),
GetEnvironmentVariable('*************************3647817'));
// Your Twilio phone number
fromPhoneNumber := '+12*******40';
// Your destination number (for trials, this needs to be your mobile #)
toPhoneNumber := '+**********20';
// Make a phone call
Writeln('----- Phone Call -----');
allParams := TStringList.Create;
allParams.Add('From=' + fromPhoneNumber);
allParams.Add('To=' + toPhoneNumber);
allParams.Add('Url=http://demo.twilio.com/docs/voice.xml');
// POST to the Calls resource
response := client.Post('Calls', allParams);
if response.Success then
Writeln('Call SID: ' + response.ResponseData.GetValue<string>('sid'))
else if response.ResponseData <> nil then
Writeln(response.ResponseData.ToString)
else
Writeln('HTTP status: ' + response.HTTPResponse.StatusCode.ToString);
1条答案
按热度按时间qojgxg4l1#
GetEnvironmentVariable
在传入键时检索一个值。假设你有一个键/值对,
TWILIO_ACCOUNT_SID=1234356789
。要访问该值,您需要传入密钥:GetEnvironmentVariable('TWILIO_ACCOUNT_SID')
。在你的代码片段中,你传递的是值本身(即
*************************a271d22b1
)您应该首先设置环境变量。
作为一个快速的解决方法,你可以传入:
但你肯定会想把你的证件藏起来。