我试图让twilio与我的网站发送短信。
以下是我采取的步骤,
首先,我下载了最新的repo,并将Twilio文件夹放在/libraries下
然后我加了一句,
$config['composer_autoload'] = '/libraries/Twilio/autoload.php';
字符串
到http://www.php
然后在我的控制器中,
我有一个功能,
$number = 'xx';
$country = '1';
$to = '+'.$country.$number;
require(APPPATH . "/libraries/Twilio/autoload.php");
// Use the REST API Client to make requests to the Twilio REST API
// Your Account SID and Auth Token from twilio.com/console
$sid = "xx"; // Your Account SID from www.twilio.com/console
$token = "xx";
$client = new Twilio\Rest\Client($sid, $token);
// Use the client to do fun stuff like send text messages!
$client->messages->create(
// the number you'd like to send the message to
$to,
array(
// A Twilio phone number you purchased at twilio.com/console
'xxx' => 'ADD Your Free/purchased Number',
// the body of the text message you'd like to send
'body' => "Hey Emir! It's Works"
)
);
型
所以我的问题是,当我运行视图时,这是我得到的错误,
遇到PHP错误
严重性:警告
Copyright © 2018 www.xxx.com/public_html/application/libraries/Twilio/Twilio/Rest/Client.php All rights reserved.
所以出于某种原因,Twilio/autoload.php在路径中添加了另一个/Twilio,我无法弄清楚。
有什么需要帮忙的吗?
2条答案
按热度按时间fgw7neuy1#
1.从存储库Twilio Php repository下载代码
2.解压缩代码,并将Twilio文件夹复制到application/libraries文件夹3.转到您(Model或Controller)想要使用库的文件。并在顶部添加这行代码。
字符串
1.现在你可以调用和使用Twilio类。
型
wfypjpf42#
字符串