TWLIO COMPISTION APIS
This commit is contained in:
parent
88c036dbae
commit
6a5f5ebe95
@ -95,6 +95,7 @@ defined('ROUTE_LOGIN_V') OR define('ROUTE_LOGIN_V', 'generateSatelliteImg
|
||||
defined('ROUTE_LOGIN_A') OR define('ROUTE_LOGIN_A', 'getAuditedImages'); // no errors
|
||||
defined('TURN_SERVER_API') OR define('TURN_SERVER_API', 'getServerInfo'); // no errors
|
||||
defined('VIDEO_CHAT_ACCESS_KEY_API') OR define('VIDEO_CHAT_ACCESS_KEY_API', 'getVideoChatAccessKey'); // no errors
|
||||
defined('SAVEROOMINFO_API') OR define('SAVEROOMINFO_API', 'saveRoomInfo'); // no errors
|
||||
//defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN','getFullPDDetails'); // no errors
|
||||
|
||||
/*********************AWS resources Constants*************************************************/
|
||||
|
||||
@ -235,6 +235,7 @@ $route['duplicatePD'] = 'PD_Controller/duplicatePD';
|
||||
$route['saveApplicantImgFromVendorForm'] = 'PD_Controller/saveApplicantImgFromVendorForm';
|
||||
$route['loadCreditPDTemplate'] = 'PD_Controller/loadCreditPDTemplate';
|
||||
$route['saveRoomInfo'] = 'PD_Controller/saveRoomInfo';
|
||||
$route['updateTwlioVideoStatus'] = 'PD_Controller/updateTwlioVideoStatus';
|
||||
// $route['getPDFormDetailsJSON'] = 'PD_Controller/getPDFormDetailsJSON';
|
||||
|
||||
$route['smartyTestFunction'] = 'PD_Controller/smartyTestFunction';
|
||||
|
||||
@ -9678,40 +9678,71 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
|
||||
{
|
||||
$pd_id = $this->post('pd_id');
|
||||
$random_string = $this->post('random_string');
|
||||
$pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id,$random_string);
|
||||
//$pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id);//,$random_string);
|
||||
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id'];
|
||||
$this->load->library('twlio');
|
||||
$result_data = array();
|
||||
//echo $bucket_name;
|
||||
$query = "SELECT * FROM ".CUS_VIDEO." where fk_pd_id = $pd_id and is_active = 1 group by video_key";
|
||||
//$video_info = $this->PD_Model->selectCustomRecords(array('*'),array('fk_pd_id' => $pd_id,'is_active' => 1,'video_key' => $video_key),CUS_VIDEO);
|
||||
$query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pd_id and is_call_ended = 1 and composition_id is not null";
|
||||
$video_info = $this->db->query($query);
|
||||
if($video_info->num_rows())
|
||||
{
|
||||
$video_info = $video_info->result_array();
|
||||
//print_r($video_info);die();
|
||||
foreach ($video_info as $key => $value)
|
||||
{
|
||||
if($value['video_key'] != null && $value['video_key'] != "")
|
||||
$video_name = $value['composition_id'].'.mp4';
|
||||
if($value['twilo_status'] == 'completed')
|
||||
{
|
||||
$video_name = $pd_id.'-'.$value['video_key'].'.mp4';
|
||||
$final_key = 'pd'.$pd_id.'/video/'.$video_name;
|
||||
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$final_key,'+7 days');
|
||||
$result_data[] = array('video_name' => $video_name, 'url' => $singed_uri);
|
||||
$singed_uri = $this->twlio->compositionVideoFile($value['composition_id']);
|
||||
$result_data[] = array('video_name' => $video_name, 'url' => $singed_uri,'status' => $value['twilo_status']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result_data[] = array('video_name' => $video_name, 'url' => '','status' =>'processing');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//print_r($video_info);die();
|
||||
|
||||
|
||||
|
||||
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['records'] = $result_data;
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function updateTwlioVideoStatus_post()
|
||||
{
|
||||
$pd_id = $this->post('pd_id');
|
||||
$random_string = $this->post('random_string');
|
||||
$this->load->library('twlio');
|
||||
$result_data = 0;
|
||||
$query = "SELECT * FROM ".VIDEO_ROOM_INFO." where fk_pd_id = $pd_id and twilo_status = 'enqueued' and composition_id is not null;";
|
||||
$video_info = $this->db->query($query);
|
||||
if($video_info->num_rows())
|
||||
{
|
||||
$video_info = $video_info->result_array();
|
||||
//print_r($video_info);die();
|
||||
foreach ($video_info as $key => $value)
|
||||
{
|
||||
$res = $this->twlio->getCompositionStatus($value['composition_id']);
|
||||
//echo $res['status'];
|
||||
if(count($res) && $res['status'] == 'completed')
|
||||
{
|
||||
$id = $this->PD_Model->updateRecords(array('twilo_status' => 'completed'),VIDEO_ROOM_INFO,array('video_room_info_id' => $value['video_room_info_id']));
|
||||
if($id){ $result_data++ ;}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['records'] = $result_data;
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function mergeVideo($pd_id,$pd_master_details,$final_video_name,$video_key)
|
||||
@ -10769,7 +10800,9 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
|
||||
{
|
||||
// $this->load->library('twlio');
|
||||
|
||||
// $this->twlio->getCompositionStatus('CJaaea12da88661de0e49612e5eb6130b3');die();
|
||||
// $tata = $this->twlio->compositionVideoFile('CJ89555fef0f0e70c18d22cbae1d812daa');
|
||||
// //print_r($tata);
|
||||
// die();
|
||||
$records = $this->post('records');
|
||||
$id = null;
|
||||
//print_r($records);
|
||||
@ -10788,6 +10821,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
|
||||
// print_r($composition_result_data_json);
|
||||
$records['res_json'] = $composition_result_data_json;
|
||||
$records['twilo_status'] = $composition_result_data['status'];
|
||||
$records['composition_id'] = $composition_result_data['compositionId'];
|
||||
$id = $this->PD_Model->updateRecords($records,VIDEO_ROOM_INFO,array('room_id' => $records['room_id'],'fk_pd_id' => $records['fk_pd_id']));
|
||||
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ class AUTHORIZATION
|
||||
}
|
||||
|
||||
|
||||
if( $routingName == ROUTE_LOGIN_X || $routingName == ROUTE_LOGIN_Y || $routingName == ROUTE_LOGIN_Z || $routingName == ROUTE_LOGIN_W || $routingName == ROUTE_LOGIN_V || $routingName == ROUTE_LOGIN_A || $routingName == TURN_SERVER_API || $routingName == VIDEO_CHAT_ACCESS_KEY_API)
|
||||
if( $routingName == ROUTE_LOGIN_X || $routingName == ROUTE_LOGIN_Y || $routingName == ROUTE_LOGIN_Z || $routingName == ROUTE_LOGIN_W || $routingName == ROUTE_LOGIN_V || $routingName == ROUTE_LOGIN_A || $routingName == TURN_SERVER_API || $routingName == VIDEO_CHAT_ACCESS_KEY_API || $routingName ==SAVEROOMINFO_API)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -209,8 +209,36 @@ class Twlio
|
||||
$composition = $client->video->compositions($composition_id)
|
||||
->fetch();
|
||||
|
||||
echo $composition->sid;
|
||||
print($composition);
|
||||
$result_array['compositionId'] = $composition->sid;
|
||||
$result_array['accountSid'] = $composition->accountSid;
|
||||
$result_array['status'] = $composition->status;
|
||||
$result_array['dateCreated'] = $composition->dateCreated;
|
||||
$result_array['dateCompleted'] = $composition->dateCompleted;
|
||||
$result_array['roomSid'] = $composition->roomSid;
|
||||
$result_array['dateDeleted'] = $composition->dateDeleted;
|
||||
$result_array['audioSources'] = $composition->audioSources;
|
||||
$result_array['audioSourcesExcluded'] = $composition->audioSourcesExcluded;
|
||||
$result_array['videoLayout'] = $composition->videoLayout;
|
||||
$result_array['resolution'] = $composition->resolution;
|
||||
$result_array['trim'] = $composition->trim;
|
||||
$result_array['format'] = $composition->format;
|
||||
$result_array['bitrate'] = $composition->bitrate;
|
||||
$result_array['size'] = $composition->size;
|
||||
$result_array['duration'] = $composition->duration;
|
||||
$result_array['url'] = $composition->url;
|
||||
$result_array['links'] = $composition->links;
|
||||
return $result_array;
|
||||
}
|
||||
|
||||
function compositionVideoFile($composition_id)
|
||||
{
|
||||
$apiKeySid = TWILIO_API_KEY;
|
||||
$apiKeySecret = TWILIO_API_KEY_SECRET;
|
||||
$client = new Client($apiKeySid, $apiKeySecret);
|
||||
$uri = "https://video.twilio.com/v1/Compositions/$composition_id/Media?Ttl=3600";
|
||||
$response = $client->request("GET", $uri);
|
||||
$mediaLocation = $response->getContent()["redirect_to"];
|
||||
return $mediaLocation;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user