PHP code example of actengage / laravel-message-gears
1. Go to this page and download the library: Download actengage/laravel-message-gears 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/ */
actengage / laravel-message-gears example snippets php
// config/services.php
return [
'messagesgears' => [
'api_key' => '...',
'account_id' => '...',
'campaign_id' => '...',
]
]
php
use Actengage\MessageGears\Notifications\SendTransactionalCampaign;
$user = new User();
$user->email = '[email protected] ';
$user->save();
$user->notify(new SendTransactionalCampaign([
'campaignId' => 'CAMPAIGN_ID'
]));
php
app('messagegears')->submitTransactionCampaign([
'campaignId' => 'CAMPAIGN_ID',
'recipient' => [
'email' => '[email protected] '
]
]);
php
use Actengage\MessageGears\TransactionalCampaignSubmit;
$message = (new TransactionalCampaignSubmit)
->accountId(1)
->apiKey('API_KEY')
->to('[email protected] ')
->context('some.nested.context', true);
app('messagegears')->submitTransactionalCampaign($message)
php
namespace Actengage\MessageGears\Notifications;
use Illuminate\Notifications\Notification;
use Actengage\MessageGears\TransactionalCampaignChannel;
use Actengage\MessageGears\Messages\TransactionalCampaignSubmit;
class SendTransactionalCampaign extends Notification
{
/**
* The notification params.
*
* @var array $params
*/
public $params;
/**
* The notification constructor.
*
* @param array $params
* @return void
*/
public function __construct(array $params = [])
{
$this->params = $params;
}
/**
* Get the notification channels.
*
* @param mixed $notifiable
* @return array|string
*/
public function via($notifiable)
{
return [TransactionalCampaignChannel::class];
}
/**
* Cast the notification as a transactional campaign message.
*
* @param array $params
* @return \Actengage\MessageGears\TransactionalCampaignSubmit
*/
public function toTransactionalCampaign($notifiable)
{
return new TransactionalCampaignSubmit($this->params);
}
}