且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Twilio 使用 twilio 库发送消息

更新时间:2023-01-23 18:34:09

您好,这里是 Twilio 开发人员布道者.

Hi Twilio developer evangelist here.

很抱歉听到您的代码有问题.

Sorry to hear you're having trouble with your code.

您似乎没有发布完整的代码,所以我看不到您实际需要该库的位置.

You seem to not have posted your complete code, so I don't see where you actually require the library.

不过,我写了一个对我有用的例子.

I have however written an example which worked for me.

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = 'AC'; 
$token = '01'; 
$client = new \Services_Twilio($sid, $token);

$message = $client->account->messages->sendMessage(
    '+44', // From a valid Twilio number
    '+44', // Text this number
    "Hello monkey!"
);

我删除了代码中的一些敏感数据,但如果您将其替换为您的令牌和数字,您应该能够正确发送短信.

I have removed some sensitive data on the code, but if you replace that with your token and numbers, you should be able to send a text message correctly.

另外,如果您在其他地方有服务"文件夹的内容,请确保您的路径正确.

Also, just in case you have the contents of the 'Services' folder elsewhere, make sure your paths are correct.