未找到 Twilio 响应 Class
Twilio Response Class not found
我是 Twilio 的新手。要学习基础知识,我按照此处的说明进行操作:
https://www.twilio.com/docs/howto/walkthrough/click-to-call/php/laravel#12
起初,我的 phone 会响铃,我会收到一条普通消息。印象深刻,我升级了我的帐户。现在我接到一个电话,声音说 "We're sorry an application error has occurred."
我检查了 Twilio 中的警报,发现 错误:12100 - 文档解析失败
所以我检查了我的outbound.php的url,发现这里有一个PHP错误。错误是
Fatal error: Class 'Response' not found in
/home/......./outbound.php on line 16
经过一番搜索,我找不到其他人讨论同样的问题。最后,最糟糕的是,我什至无法在 Twilio Helper Library 中找到对 Response class 的任何引用。
这是我针对相关页面的整个代码块。
<?php
error_reporting(E_ALL);
require_once 'twilio-library/Services/Twilio.php';
// A message for Twilio's TTS engine to repeat
$sayMessage = 'Thanks for contacting our sales department. If this were a
real click to call application, we would redirect your call to our
sales team right now using the Dial tag.';
$twiml = new Services_Twilio_Twiml();
$twiml->say($sayMessage, array('voice' => 'alice'));
// $response->dial('+12345675309');
$response = Response::make($twiml, 200);
$response->header('Content-Type', 'text/xml');
return $response;
?>
如果我将此文件更改为格式正确的静态文件 XML,则错误将停止。
这里是 Twilio 开发人员布道者。
您所关注的教程基于 Laravel framework,这是 Response
class 预期的来源。
如果您只是在普通 PHP 文件中使用 PHP TwiML 生成器,您应该能够 print
$twiml
。为了安全起见,我可能还会添加 text/xml 的 Content-Type。像这样:
<?php
error_reporting(E_ALL);
require_once 'twilio-library/Services/Twilio.php';
// A message for Twilio's TTS engine to repeat
$sayMessage = 'Thanks for contacting our sales department. If this were a
real click to call application, we would redirect your call to our
sales team right now using the Dial tag.';
$twiml = new Services_Twilio_Twiml();
$twiml->say($sayMessage, array('voice' => 'alice'));
// $twiml->dial('+12345675309');
header('Content-type: application/xml');
print $twiml;
?>
如果这有帮助,请告诉我!
我是 Twilio 的新手。要学习基础知识,我按照此处的说明进行操作: https://www.twilio.com/docs/howto/walkthrough/click-to-call/php/laravel#12
起初,我的 phone 会响铃,我会收到一条普通消息。印象深刻,我升级了我的帐户。现在我接到一个电话,声音说 "We're sorry an application error has occurred."
我检查了 Twilio 中的警报,发现 错误:12100 - 文档解析失败
所以我检查了我的outbound.php的url,发现这里有一个PHP错误。错误是
Fatal error: Class 'Response' not found in /home/......./outbound.php on line 16
经过一番搜索,我找不到其他人讨论同样的问题。最后,最糟糕的是,我什至无法在 Twilio Helper Library 中找到对 Response class 的任何引用。
这是我针对相关页面的整个代码块。
<?php
error_reporting(E_ALL);
require_once 'twilio-library/Services/Twilio.php';
// A message for Twilio's TTS engine to repeat
$sayMessage = 'Thanks for contacting our sales department. If this were a
real click to call application, we would redirect your call to our
sales team right now using the Dial tag.';
$twiml = new Services_Twilio_Twiml();
$twiml->say($sayMessage, array('voice' => 'alice'));
// $response->dial('+12345675309');
$response = Response::make($twiml, 200);
$response->header('Content-Type', 'text/xml');
return $response;
?>
如果我将此文件更改为格式正确的静态文件 XML,则错误将停止。
这里是 Twilio 开发人员布道者。
您所关注的教程基于 Laravel framework,这是 Response
class 预期的来源。
如果您只是在普通 PHP 文件中使用 PHP TwiML 生成器,您应该能够 print
$twiml
。为了安全起见,我可能还会添加 text/xml 的 Content-Type。像这样:
<?php
error_reporting(E_ALL);
require_once 'twilio-library/Services/Twilio.php';
// A message for Twilio's TTS engine to repeat
$sayMessage = 'Thanks for contacting our sales department. If this were a
real click to call application, we would redirect your call to our
sales team right now using the Dial tag.';
$twiml = new Services_Twilio_Twiml();
$twiml->say($sayMessage, array('voice' => 'alice'));
// $twiml->dial('+12345675309');
header('Content-type: application/xml');
print $twiml;
?>
如果这有帮助,请告诉我!