PHP code example of pushjs / php-sdk

1. Go to this page and download the library: Download pushjs/php-sdk 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/ */

    

pushjs / php-sdk example snippets




Pushjs\Service\PushJS;

$pushJS = new PushJS('your-api-key', 'eu-1.pushjs.io', 9101);


$pushJS->getEventManager()->dispatchEvent($channelId, 'MY_EVENT', json_encode([
        'text' => 'BOOM!',
        'foo' => 'bar'
    ])
);

$pushJS->getEventManager()->dispatchPrivateEvent(
    $clientId, 
    'MY_PRIVATE_MESSAGE_EVENT', 
    'this is a private message'
);

$pushJS->getEventManager()->dispatchFilteredEvent(
    $channelId, 
    'MY_FILTERED_MESSAGE_EVENT', 
    'this should only go to to clients with attribute color and value red',
    ['color' => 'red']
);