doucheng9304 2017-10-24 12:31
浏览 30
已采纳

在twilio中获得进程中的队列

Is there any way to get Queues which have current_size greater than 0.

I want to get Queues which have current_size greater than 0, I have hundreds of Queues in the system so i want to get only specific queues.

This is what i have done. I am getting the queues having current_size 0.

function get_inprocess_queue_calls(){
   if(!$this->input->is_ajax_request()){
        exit('Direct access of script is not allowed');
    }
    require_once 'twilio/Twilio.php';
    $twilio_result=$this->broswer_call_model->twilio_credentials();
    $client = new Services_Twilio($twilio_result->twilio_accountId, $twilio_result->twilio_authtoken);
    $queues = $client->account->queues->getIterator(0, 50,array("Status" => "in-progress")); 
    $i=0;
    $data='';
    foreach ($queues as $queue) { 
        if($queue->current_size>0){
            $f_name = $queue->friendly_name;
            if($f_name!=''){
                $nameArr = array();
                $nameArr = @explode('_', $f_name);
                $leadId = $nameArr[3];
                $from_number = $nameArr[0];
                if(strpos($from_number, '+')!== false){
                    $lead_name = '';
                    if($leadId!=0){
                        $lead_record = $this->broswer_call_model->get_lead_details($leadId,$this->teamId,$this->leadTable);
                        if($lead_record!=0){
                            $lead_name = $lead_record->first_name.' '.$lead_record->last_name;
                        }
                    }
                    $fun_param1 = "'".$queue->friendly_name."'";
                    $fun_param2 = "'".$queue->sid."'";
                    $data.='<tr>
                        <td style="text-align: center;">'.$lead_name.'</td>
                        <td style="text-align: center;">'.$from_number.'</td>
                        <td style="text-align: center;">'.$queue->average_wait_time.'</td>
                        <td onclick="ConnectLead('.$fun_param1.','.$fun_param2.')" style="cursor:pointer; color:#0066FF; text-align: center;">Connect</td>
                    </tr>';
                }
            }
            $i++;
        }
    }
    echo json_encode(array('show_status'=>$i,'data'=>$data)); 
}

What I want to do is like

$queues = $client->account->queues->getIterator(0, 50,array("Status" => "in-progress"));

Or like

$queues = $client->account->queues->getIterator(0, 50,array("Current Size" => "> 0"));

Any Help would be much appreciated

Thanks

  • 写回答

1条回答 默认 最新

  • douzuqin3467 2017-10-26 06:43
    关注

    Twilio developer evangelist here.

    The documentation for the Queues resource only lists FriendlyName and MaxSize as the parameters you can use to filter the results. This doesn't include a status parameter or current length parameter, so there is no direct call you can make to the API for this.

    It looks like what you've got is probably your best bet now.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改