我正在尝试使用Twilio的测试帐户提交表单时发送短信但是我收到以下错误:'致命错误:类'Services_Twilio'未找到'
我的代码如下:
} else{
//PHP native
mail( $to_guest, $subject, $html_text, $header_guest);
// Outlet Admin notification email
mail( $to_admin, $subject, $notification_text, $header_admin);
/* Send an SMS using Twilio. You can run this file 3 different ways:
*
* - Save it as sendnotifications.php and at the command line, run
* php sendnotifications.php
*
* - Upload it to a web host and load mywebhost.com/sendnotifications.php
* in a web browser.
* - Download a local server like WAMP, MAMP or XAMPP. Point the web root
* directory to the folder containing this file, and load
* localhost:8888/sendnotifications.php in a web browser.
*/
// Step 1: Download the Twilio-PHP library from twilio.com/docs/libraries,
// and move it into the folder containing this file.
require ('http://xzenweb.co.uk/reservation/web/twilio-php/Services/Twilio.php');
// Step 2: set our AccountSid and AuthToken from www.twilio.com/user/account
$AccountSid = "";
$AuthToken = "";
// Step 3: instantiate a new Twilio Rest Client
$client = new Services_Twilio($AccountSid, $AuthToken);
// Step 4: make an array of people we know, to send them a message.
// Feel free to change/add your own phone number and name here.
$people = array(
"+44463463241" => "Andrew Charlton",
);
// Step 5: Loop over all our friends. $number is a phone number above, and
// $name is the name next to it
foreach ($people as $number => $name) {
$sms = $client->account->messages->sendMessage(
// Step 6: Change the 'From' number below to be a valid Twilio number
// that you've purchased, or the (deprecated) Sandbox number
"YYY-YYY-YYYY",
// the number we are sending to - Any phone number
+44463463241,
// the sms body
"Hey $name, Monkey Party at 6PM. Bring Bananas!"
);
// Display a confirmation message on the screen
echo "Sent message to $name";
}
}
我已经离开了我的帐户ID,并且已经从上面解密了。
有什么问题?
答案 0 :(得分:2)
所以你使用require
。
根据{{3}}和documentation之一,require会打开一个文件并逐出其背后的代码。
它在你使用它的方式中所做的是:从include获取文件(whitch什么都不返回)和evals id(evals nothing)。
这就是你的要求失败的原因。
如果您想要/包含那段coe,您应该从http://xzenweb.co.uk/reservation/web/twilio-php/Services/Twilio.php下载源代码并将其放在代码的环境中。
如果我理解Twilio是正确的,那么它们就被用作休息网络服务。 根据文件http://xzenweb.co.uk/reservation/web/twilio-php/Services/Twilio.php提交的文件 你想下载rest-client-code(就像这里描述的那样http://www.twilio.com/docs/api/rest/sending-messages),然后一切都来找你; - )