从这里看一下:https ://www.twilio.com/docs/voice/client/twiml 我能得到的最接近的是:
$response = new Twiml();
$callerIdNumber = config('services.twilio')['number'];
$dial = $response->dial(['callerId' => $callerIdNumber]);
$dial->parameter([
"name" => "firstname",
"value" => "Test Firstname",
]);
$dial->parameter([
"name" => "lastname",
"value" => "Test lastname",
]);
$dial->client('support_agent');
return $response;
但它会引发无效的 XML 警告:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial callerId="+12055461045">
<Parameter name="firstname" value="Test Firstname"/>
<Parameter name="lastname" value="Test lastname"/>
<Client>support_agent</Client>
</Dial>
</Response>
在文档中,它应该看起来像这样:
<Response>
<Dial>
<Client>
<Identity>joey</Identity>
<Parameter name="firstname" value="Test Firstname"/>
<Parameter name="lastname" value="Test lastname"/>
</Client>
</Dial>
</Response>
我已经尝试了很多东西,但它们都引发了应用程序错误。这是我尝试过的两个。我试过的其他东西我已经忘记了。
// trial 1
$dial->client->identity('support_agent')
$dial->client->parameter([
"name" => "firstname",
"value" => "Test Firstname",
]);
//trial 2
$dial->client->identity('support_agent', array('parameter' => [
"name" => "firstname",
"value" => "Test Firstname",
]))
任何帮助将非常感激!
呼啦一阵风