John Davidson

php - Twilio video get all the rooms both with status 'in-progress' and completed

0 comments
Message:


I am trying to use twilio api with laravel, and here is my code to fetch the list of rooms.


Currently, I have to query twice with status in-progress and completed status, is there any way to get rooms with both status at the same time?


My code:


$twilio = new Client($this->sid, $this->token);
$rooms = $twilio->video->rooms->read(
[
// "type" => "group",
// "status" => "in-progress",
"status" => "completed"
],
20
);

I have also tried by commenting status parameter and only sends with type param but there was no response with that.


All I want is to be fetch all rooms with both status in-progress and completed



My Answer:
To get all the rooms with their status in Twilio video, you can use the Twilio REST API to retrieve a list of rooms and their status. Here is an example code snippet in PHP to achieve this:

php

// Include the Twilio PHP library
require __DIR__ . '/vendor/autoload.php';
use Twilio\Rest\Client;

// Your Twilio Account SID and Auth Token
$accountSid = 'your_account_sid';
$authToken = 'your_auth_token';

// Initialize the Twilio client
$client = new Client($accountSid, $authToken);

// Get a list of rooms
$rooms = $client->video->rooms->read();

// Loop through each room and display its status
foreach ($rooms as $room) {
echo "Room SID: " . $room->sid . "\n";
echo "Room Name: " . $room->uniqueName . "\n";
echo "Room Status: " . $room->status . "\n";
echo "\n";
}


Make sure to replace `'your_account_sid'` and `'your_auth_token'` with your actual Twilio Account SID and Auth Token. This code snippet will retrieve a list of rooms and display their SID, unique name, and status.

Rate this post

3 of 5 based on 8689 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us