<?php
namespace BoostN\Slack\Service;
use XF\Service\AbstractService;
class SlackNotify extends AbstractService
{
public function postToSlack(array $payload)
{
$app = \XF::app();
$epayload = json_encode($payload);
$webHook = $app->options()->boostnSlackwebHook;
$ch = curl_init($webHook);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $epayload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$response = curl_exec ($ch); // execute
curl_close ($ch); // close curl handle
return $response;
}
}
<?php
namespace BoostN\Slack\XF\Service\User;
class Registration extends XFCP_Registration
{
protected function notifySlack()
{
parent::sendRegistrationContact();
$app = \XF::app();
$payload = array (
'attachments' =>
array (
0 =>
array (
'text' => 'Something is broken',
'title' => 'From Registration.php Class Ext',
'title_link' => 'https://google.com',
),
),
'channel' => '#general',
'icon_emoji' => ':exclamation:',
'icon_url' => NULL,
'text' => 'Test from XenForo',
'username' => $app->options()->boostnSlackuserName,
);
if($app->options()->boostnSlackenableNewUserReg)
{
/** @var \BoostN\Slack\Service\SlackNotify $slackService */
$slackService = $this->service('BoostN\Slack:SlackNotify');
$slackService->postToSlack($payload);
}
}
}
protected function notifySlack()
protected function sendRegistrationContact()
We use essential cookies to make this site work, and optional cookies to enhance your experience.