PHP code example of volkerschulz / sse-client
1. Go to this page and download the library: Download volkerschulz/sse-client library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
volkerschulz / sse-client example snippets
use volkerschulz\SseClient;
$client = new SseClient('https://example.com');
foreach($client->getEvents() as $event) {
// Handle single event
echo $event->getData();
}
use volkerschulz\SseClient;
$sse_options = [
'reconnect' => false,
'read_timeout' => 5
];
$client = new SseClient('https://example.com', $sse_options);
$http_options = [
'json' => [
'foo' => 'bar'
],
'allow_redirects' => false
];
foreach($client->getEvents($http_options, 'POST') as $event) {
// Handle single event
}