Untitled

 avatar
user_3839718
php
a year ago
1.1 kB
2
Indexable
Never
$streamDetails = $this->robotManager->getStreamingDetails($robotId);
if ($streamDetails !== null) {
    try {
        $adapter = new \Laminas\Http\Client\Adapter\Curl();
        $adapter->setCurlOption(CURLOPT_FOLLOWLOCATION, true);
        
        // Check if the URL is not null and is a string before performing replacement
        if ($streamDetails->url_in !== null && is_string($streamDetails->url_in)) {
            // Replace "https" with "http" in the URL
            $url_in = str_replace("https", "http", $streamDetails->url_in);
        } else {
            $url_in = null; // Simulating a null value for the else block (for demonstration purposes only)
        }

        $url_details = "This is the URL: " . $url_in;
        error_log("Streaming about to start: $url_details", E_USER_NOTICE);
        $uri = $url_in . "/" . $streamDetails->stream_id;
        $client = new \Laminas\Http\Client($uri);
        $client->setAdapter($adapter);

        $client->setOptions([
            "timeout" => 2
        ]);

        $response = $client->send()->getBody();