0) { foreach($data['chunk'] as $message) { if($message['sender'] != $sender_name) { if($message['content']['msgtype'] == "m.text") { if(!empty($message['content']['body'])) { $nick_parts = explode(":", $message['sender']); $relay = "[".substr($nick_parts[0],1)."] ".$message['content']['body']; echo $relay."\n"; send_owncast_system_message($relay); } } } } } sleep(10); } function send_owncast_system_message($str) { if(empty($str)) return false; $url = "http://owncast_server.com"; $access_token = "YOUR_OWNCAST_ACCESS_TOKEN_HERE"; // you may have to escape hyphens with a backslash $endpoint = "/api/integrations/chat/system"; $post = array("body" => $str); $auth = "Authorization: Bearer $access_token"; $ch = curl_init($url.$endpoint); $headers = array("Content-Type: application/json", $auth); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($post)); $result = curl_exec($ch); curl_close($ch); }