1. Go to this page and download the library: Download shieldon/messenger 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/ */
shieldon / messenger example snippets
composer
$apiKey = 'your_api_key';
$channel = '@your_channel';
$telegram = new \Shieldon\Messenger\Telegram($apiKey, $channel);
if ($telegram->send('say something!')) {
echo 'Message has been sent to your Telegram group.';
} else {
echo 'Failed to send message.' . "\n";
echo $telegram->printResult();
}
$accessToken = 'your_access_token';
$line = new \Shieldon\Messenger\LineNotify($accessToken);
if ($line->send('say something!')) {
echo 'Message has been sent to your Line group.';
} else {
echo 'Failed to send message.' . "\n";
echo $line->printResult();
}
$accessToken = 'your_auth_token';
$userId = 'your_user_id';
$serverUrl = 'https://your_rocket_chat.com:3000';
$channel = '#general';
$rocketChat = new \Shieldon\Messenger\RocketChat($accessToken, $userId, $serverUrl, $channel);
if ($rocketChat->send('say something!')) {
echo 'Message has been sent to your RocketChat channel.';
} else {
echo 'Failed to send message.' . "\n";
echo $rocketChat->printResult();
}
$botToken = 'xoxb-551837935968-920623655894-TI1zWtaDLCkTzZaFFuyfzL56';
$channel = '#general';
$slack = new \Shieldon\Messenger\Slack($botToken, $channel);
if ($slack->send('say something!')) {
echo 'Message has been sent to your Slack channel.';
} else {
echo 'Failed to send message.' . "\n";
echo $slack->printResult();
}
$webhook = 'https://hooks.slack.com/services/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';
$slack = new \Shieldon\Messenger\SlackWebhook($webhook);
if ($slack->send('say something!')) {
echo 'Message has been sent to your Slack channel.';
} else {
echo 'Failed to send message.' . "\n";
echo $slack->printResult();
}
$mail = new \Shieldon\Messenger\Mail();
$mail->addSender('[email protected]');
$mail->addRecipient('[email protected]');
$mail->setSubject('Foo, bar.');
if ($mail->send('say something!')) {
echo 'Email has been delivered via PHP\'s native mail function.';
} else {
echo 'Failed to send email.' . "\n";
echo $maingun->printResult();
}
$user = 'email@your_domain.com';
$pass = '12345678';
$host = '127.0.0.1';
$port = '25';
$mail = new \Shieldon\Messenger\Smtp($user, $pass, $host, $port);
$mail->addSender('email@your_domain.com');
$mail->addRecipient('[email protected]');
$mail->setSubject('Foo, bar.');
if ($mail->send('say something!')) {
echo 'Email has been delivered via SMTP.';
} else {
echo 'Failed to send email.' . "\n";
echo $maingun->printResult();
}