在不知道sid的情况下检索php中的twilio转录文本

在不知道sid的情况下检索php中的twilio转录文本,php,twilio,Php,Twilio,我正在开发一款twilio应用程序,它将声音转录,然后转换成文本。在检索转录文本之前,一切都是正常的。我知道,如果我知道sid,我可以检索转录代码,但是如果我想动态获取转录代码而不知道sid,该怎么办。换句话说,我想从电话号码555-555-1212最新的转录我能找到的是下面的代码 <?php // Get the PHP helper library from twilio.com/docs/php/install require_once('/path/to/twilio-php/Se

我正在开发一款twilio应用程序,它将声音转录,然后转换成文本。在检索转录文本之前,一切都是正常的。我知道,如果我知道sid,我可以检索转录代码,但是如果我想动态获取转录代码而不知道sid,该怎么办。换句话说,我想从电话号码555-555-1212最新的转录我能找到的是下面的代码

<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "AC1240edf87a1d3b6717472af6deda4ce7";
$token = "{{ auth_token }}";
$client = new Services_Twilio($sid, $token);
$client->account->transcriptions->delete("TR8c61027b709ffb038236612dc5af8723");
?>
提前谢谢!
Diego

您需要获取通话的SID,但如果您知道电话号码,并且可以选择查找my PHP的日期范围已生锈,则这很容易做到,因此您可能需要对此进行修补:

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "{{ sid }}"; 
$token = "{{ auth_token }}"; 
$client = new Services_Twilio($sid, $token);

// Get calls to a number on or after a certain date.
foreach ($client->account->calls->getIterator(0, 50, array("Status" => "completed", "To" => "555-555-1212","StartTime" => "2013-10-26")) as $call)  {
    echo $call->sid
    //now use the sid to get the transcription text using a seperate rest call.
    $transcription = $client->account->transcriptions->get($call->sid);
    echo $transcription->transcription_text;    
}

修正我原来的问题=

<?php
//RETRIEVE NUMBERS LAST TRANSCRIPTION
$client = new Services_Twilio($sid, $token);
$i=0;
foreach($client->account->transcriptions->getIterator(0, 50, array('Status' =>  'completed', 'To' => ''.$_GET['number'].'')) as $call)  {  
//now use the sid to get the transcription text using a seperate rest call.
if($i==1) break;
$transcription = $client->account->transcriptions->get($call->sid);
$sms_text = $transcription->transcription_text;
$i++;
}
?>

这里是Twilio福音传道者

另一个选项是,如果使用动词is to,则可以设置transcribeCallback参数:

这可以让你给Twilio一个URL,我们将在转录完成后请求它


希望有帮助。

echo$transcription->transcription\u text;抛出以下错误->致命错误:未捕获异常“Services\u Twilio\u RestException”,并显示消息“未找到请求的资源”,似乎调用sid和转换sid完全不同。。。