PHP code example of notific / notific-php-sdk

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

    

notific / notific-php-sdk example snippets


$notific = new Notific\PhpSdk\Notific(APP_ID, API_TOKEN);

$notific->publicNotifications();

$notific->publicNotifications([
    'page' => 2,
    'limit' => 25,
    'sort' => '-created_at'
]);

$notific->createPublicNotification([
    'title' => 'Welcome!'
    'body'  => 'This is the body of the notification...'
]);

$notification = $notific->publicNotification($id);

$notification->update([
  'title' => 'Boom!'
  'body'  => 'This is the updated body of the notification.'
]);

$notification->delete();

$notific->recipients();

$notific->createRecipient([
    'id'    => '123', // Unique identifier for the user. You can use integers, hashes or what ever suites you best.
    'name'  => 'Kung Fury',
    'email' => '[email protected]'
    'phone' => '+358 40 123 456' // You can add meta information to recipient as key => value pairs.
]);

$recipient = $notific->recipient($id);

$recipient = $recipient->update([
    'name'  => 'Fury'
]);

$recipient = $recipient->tag([
    'Foo', 'Bar', 'Baz'
]);

$recipient = $recipient->removeTags([
    'Bar'
]);

$recipient = $recipient->removeAllTags();

$notific->templates();

$notific->createTemplate([
    'title' => 'Lorem ipsum dolor sit amet.',
    'body'  => 'Lorem ipsum dolor sit amet, consectetur adipiscing...',
    'name' => 'lorem-ipsum'
]);

$template = $notific->template($name);

$notific->privateNotifications();

$notific->privateNotifications([
    'filter[type]' => '1,2',
    'sort' => '-created_at'
]);

$notific->createPrivateNotification([
    'title' => 'Welcome!'
    'body'  => 'This is the body of the private notification...'
]);

$notification = $notific->privateNotification($id);

$notification->update([
  'title' => 'Boom!'
  'body'  => 'This is the updated body of the private notification.'
]);

$data = $notific->template($name)->recipients($recipients)->send()

$data = $notific->privateNotification($notificationId)->recipients($recipients)->send()

$data = $notific->template($name)->recipients($recipients)->channels('broadcast', 'email')->send()

$data = $notific->privateNotification($notificationId)->recipients($recipients)->channels('broadcast')->send()

 $data = $notific->template($name)->tags($tags)->send()
 

$data = $notific->privateNotification($notificationId)->tags($tags)->send()

 $data = $notific->template($name)->tags('all')->send()
 

$data = $notific->privateNotification($notificationId)->tags('all')->send()

$data = $notific->template($id)->sendTo($recipients);

$data = $notific->privateNotification($notificationId)->sendTo($recipients);

$data = $notific->recipient($id)->sendNotification($notificationId);

$data = $notific->template($name)->test();

$data = $notific->privateNotification($id)->test();