PHP code example of superbalist / php-localytics-push

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

    

superbalist / php-localytics-push example snippets


$client = new GuzzleHttp\Client();
$appID = 'your-app-id';
$apiKey = 'your-api-key';
$apiSecret = 'your-api-secret';

$localytics = new \Superbalist\LocalyticsPush\LocalyticsPush($client, $appID, $apiKey, $apiSecret);
$message = [
    'target' => [
        'profile' => [
            'criteria' => [
                [
                    'key' => '$email',
                    'scope' => 'Organization',
                    'type' => 'string',
                    'op' => 'in',
                    'values' => [
                        '[email protected]',
                    ]
                ]
            ],
            'op' => 'and',
        ],
    ],
    'alert' => [
        'title' => 'Message Title',
        'body' => 'This is my message content!',
    ]
];
$response = $localytics->pushMessage('profile', $message);