Created
February 14, 2026 03:46
-
-
Save gbowne1/a1119991ae86937dc4c45be5701f2c04 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require 'vendor/autoload.php'; | |
| use SoureCode\ObsWebsocket\Client; | |
| use SoureCode\ObsWebsocket\Request\Record\ToggleRecordRequest; | |
| // 1. Initialize the client | |
| // Replace 'your_password' with the password from OBS WebSocket settings | |
| $client = new Client('ws://127.0.0.1:4455', 'your_password'); | |
| try { | |
| // 2. Connect to OBS | |
| // The library handles the 'Hello'/'Identify' handshake automatically | |
| $client->connect(); | |
| echo "Successfully connected to OBS!\n"; | |
| // 3. Send a Request (Example: Toggle Recording) | |
| $response = $client->send(new ToggleRecordRequest()); | |
| if ($response->isSuccess()) { | |
| echo "Recording toggled successfully.\n"; | |
| } else { | |
| echo "Failed to toggle recording: " . $response->getError() . "\n"; | |
| } | |
| // 4. Close connection when done | |
| $client->disconnect(); | |
| } catch (\Exception $e) { | |
| echo "Connection error: " . $e->getMessage() . "\n"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment