gpt4 book ai didi

php - twilio '未知上下文帐户

转载 作者:行者123 更新时间:2023-12-03 23:03:48 25 4
gpt4 key购买 nike

我正在尝试使用 Php 通过 Twilio 发送简单的 SMS,但我收到了这个 fatal error ,

Uncaught exception 'Twilio\Exceptions\TwilioException' with message 'Unknown context accounts' in C:\xampp\htdocs\Twilio\vendor\twilio\sdk\Twilio\Rest\Client.php:687

Stack trace:

0 C:\xampp\htdocs\Twilio\twilio.php(24): Twilio\Rest\Client->__call('accounts', Array)

1 C:\xampp\htdocs\Twilio\twilio.php(24): Twilio\Rest\Client->accounts('AC8687f4eaba8c6...')

2 {main} thrown in C:\xampp\htdocs\Twilio\vendor\twilio\sdk\Twilio\Rest\Client.php on line 687

这是我的本地服务器代码:

<?php 
// Get the PHP helper library from twilio.com/docs/php/install
require_once 'vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;
$account_sid = 'AC8687f4eaba8c68XXXXXXXXXXXXX';
$auth_token = '6baf210351f27a38850XXXXXXXXXXXXXXXX';
$client = new Client($account_sid, $auth_token);
$messages = $client->accounts('AC8687f4eaXXXXXXXXXXX')
->messages->create('+52722XXXXXXX', array(
'From' => '+151240XXXXX',
));
?>

最佳答案

此处为 Twilio 开发人员布道师。

您似乎正试图从最初授权 PHP 库的帐户发送消息。在这种情况下,您不需要先调用帐户资源。这可能是有意遗漏,但我也注意到您的消息没有正文。

以下代码应该适合您:

<?php 
// Get the PHP helper library from twilio.com/docs/php/install
require_once 'vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;
$account_sid = 'AC8687f4eaba8c68XXXXXXXXXXXXX';
$auth_token = '6baf210351f27a38850XXXXXXXXXXXXXXXX';
$client = new Client($account_sid, $auth_token);
$messages = $client->messages->create('+52722XXXXXXX', array(
'From' => '+151240XXXXX',
'Body' => 'Hello from my PHP code!'
));
?>

关于php - twilio '未知上下文帐户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42638936/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com