Class 'Twilio\Twiml' 未在 laravel 中找到

Class 'Twilio\Twiml' not found in laravel

use Twilio\Twiml;

public function welcome(Request $request)
    {
        $twiml = new Twiml();
        if(isset($request->Digits)){
            switch($request->Digits){
                case 1:
                    $twiml->say('thank you calling us');
                    break;
                default:
                    $twiml->say('You have entered wrong key');
                    break;
            }
        } else{
            $gather = $twiml->gather(array('numDigits' => 1));
            $gather->say('Thank you for calling us. Press 1 to continue the call.');
        }

        return $twiml;
    }

当我 运行 此代码时,我收到 class Twlio/Twiml 未找到的错误。 更多详情可以查看错误截图url(https://prnt.sc/ryz1zw)。 提前致谢。

TwiML 不是 class,您需要使用 VoiceResponse 才能使用 say()

require_once './vendor/autoload.php';
use Twilio\TwiML\VoiceResponse;

$response = new VoiceResponse();
$response->say('Chapeau!', ['voice' => 'woman', 'language' => 'fr-FR']);

More on their docs.