Я пытаюсь отправить текстовое сообщение, когда форма отправлена с использованием тестовой учетной записи Twilio, однако я получаю следующую ошибку: «Неустранимая ошибка: Class» Services_Twilio «not found»Неустранимая ошибка: Class '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";
}
}
Я оставил свой идентификатор учетной записи и authtoken из вышеперечисленного.
В чем проблема?
Спасибо за это, я установил PHP в директории службы к югу но я все еще получаю ошибку –
вы исправили путь в ther require? требуется (__ DIR __. '/ мой/путь/Twilio-PHP/Услуги/Twilio.php')? Вам нужно отрегулировать путь, но, начиная с этого примера, вы должны выполнить его. – floww
__DIR__ должно быть с двумя символами подчеркивания до и после ... , как описано здесь: http://php.net/manual/de/language.constants.predefined.php – floww