PHP 错误:“在非对象上调用成员函数 create()"Twilio 代码

编程入门 行业动态 更新时间:2024-10-21 19:41:53
本文介绍了PHP 错误:“在非对象上调用成员函数 create()"Twilio 代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送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:关键词]

本文发布于:2023-04-29 16:34:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1192118.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   对象   成员   错误   代码

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!