PHP code example of mirovit / onesignal

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

    

mirovit / onesignal example snippets




 default, if a token is not passed in the constructor,
// the class will try to load the token from
// ONESIGNAL_API_KEY environment variable. The second param,
// the API endpoint is set as default value to
// https://onesignal.com/api/v1, which is the current endpoint:
$sdk = new Mirovit\OneSignal\OneSignal();
// or explicitly them:
$sdk = new Mirovit\OneSignal\OneSignal(
    'rest api key',
    'api endpoint'
);

// Retrieve player
$user = $sdk
            ->players()
            ->get('player-id', ['app_id' => 'app-id']);


// https://documentation.onesignal.com/reference
$sdk
    ->players()
    ->all();

// https://documentation.onesignal.com/reference#view-device
$sdk
    ->players()
    ->get('player-id', ['app_id' => 'app-id']);

// https://documentation.onesignal.com/reference#edit-device
$sdk
    ->players()
    ->update([
        // 


// https://documentation.onesignal.com/reference#create-notification
$sdk
    ->notifications()
    ->create([
        'app_id'   => 'app-id',
         'filters'  => (new \Mirovit\OneSignal\Filters())
             ->tag('key', 'value')
             ->orWhere()
             ->tag('key', 'relation', 'value')
             ->country('bg')
             ->email('[email protected]'),
         'contents' => [
             'en' => 'test',
         ],
     ]);