PHP code example of manavo / chatty

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

    

manavo / chatty example snippets


$slackUrl = 'https://my.slack.com/services/hooks/incoming-webhook?token=XXXXXXXXXX';
$slackParams = array(
	'url' => $slackUrl,
	'username' => 'Chatty',
	'icon' => 'https://www.crystalvaults.com/images/bagua-square.gif',
);

$chatty = new \Manavo\Chatty\Sender(new \Manavo\Chatty\MessageHandlers\Slack($slackParams));
$chatty->send($message);

$hipchatParams = array(
	'token' => '123456789123456789',
	'room_id' => 'Notifications',
	'from' => 'Chatty',
	'color' => 'random',
	'notify' => 0,
);

$chatty = new \Manavo\Chatty\Sender(new \Manavo\Chatty\MessageHandlers\Hipchat($hipchatParams));
$chatty->send($message);

class MyHandler implements \Manavo\Chatty\Interfaces\MessageHandlerInterface {

	public function handle($message)
	{
		echo $message.PHP_EOL;
	}

}

$chatty = new \Manavo\Chatty\Sender(new MyHandler());
$chatty->send($message);