问题描述
限时送ChatGPT账号..我正在尝试让 Twilio-PHP 代码的一个版本正常工作.我在这里托管了它和 Twilio 库.
I'm trying to get a version of Twilio-PHP code working. I've hosted it and the Twilio library here.
在这一行抛出一个错误:
An error is thrown on this line:
$response = $client->account->sms_messages->create($from,$number,$text);
它抛出错误:
"Call to member function create() on a non-object"
我将上面的 $from
、$number
和 $text
定义为字符串.前两个是经过验证的 Twilio $text="Hi";
.调用的语法是从该 GitHub 的快速入门部分剪切和粘贴的,因此更有可能是我没有正确使用代码.
I define $from
, $number
, and $text
above as strings. The first two are verified Twilio $text="Hi";
. The syntax of the call is cut and paste from the Quickstart section of that GitHub and so it is more likely that I am not using the code properly.
这个没有足够的解释 问题让我了解错误信息.
There wasn't enough explanation in this question for me to understand the error message.
实际代码
<?php
require './twilio-php/Services/Twilio.php';
$AccountSid = X;
$AuthToken =X;
$client = new Services_Twilio($AccountSid,$AuthToken);
$number = "1111";
$text = "This is a test";
$from = "2222";
$response = $client->account->sms_smessages->create($from,$number,$text);
?>
注意:我用假人替换了真实数字和授权令牌.
Note: I replaced the real numbers and authorization tokens with dummies.
推荐答案
$response = $client->account->sms_messages->create($from,$number,$text);
您在 sms_messages 中有一个错字
You had a typo in sms_messages
这篇关于PHP 错误:“在非对象上调用成员函数 create()"Twilio 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论