PHP code example of warrickbayman / incus

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

    

warrickbayman / incus example snippets


use Incus\Incus;
use Incus\Listener;

class MyMandrillApp extends Controller
{
	public funtion webhooks()
	{
		Incus::listen(function(Listener $listener)
		{			
			$listener->send(function($event)
			{
				...
				...
			})
			
			->open(function($event)
			{
				...
				...
			});
			
			->softBounce(function($event)
			{
				...
				...
			});
		});
	}
}

class MyMandrillApp extends Controller
{
	public function webhooks()
	{
		$events = Incus::listen();
		
		foreach ($events as $event) {
			echo "Event occured: " . $event->at()->format('d F Y');
		}		
	}
}

$listener
	->send()
	->deferral()
	->open()
	->click()
	->softBounce()
	->hardBounce()
	->spam()
	->unsub()
	->reject()

$listener->send(function($event)
{
	echo $event->at()->format('d F Y');
});

	if ($event->indexed()) {
		echo 'Message has been indexed'
	}

$listener->softBounce(function($event))
{
	$message = $event->message();
	Log::info('Message was sent to ' . $message->to());
}

$listener->click(function($event)
{
	if ($event->raw()->user_agent_parsed->mobile) {
		echo 'User agent is mobile!';
	}
});

$events = Incus::listen();
foreach ($events as $event) {
	if ($event->type() === Listener::EVENT_CLICK) {
		Log::info('Click event!');
	}
}

$listener->click(function($event)
{
    if ($event->message()->metadata()->has('user_id')) {
        $userId = $event->message->metadata()->get('user_id');
    }
});