<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
laravel-notification-channels / facebook example snippets
// config/services.php
...
'facebook' => [
'page-token' => env('FACEBOOK_PAGE_TOKEN', 'YOUR PAGE TOKEN HERE'),
// Optional - Omit this if you want to use default version.
'version' => env('FACEBOOK_GRAPH_API_VERSION', '4.0')
// Optional - If set, the appsecret_proof will be sent to verify your page-token.
'app-secret' => env('FACEBOOK_APP_SECRET', '')
],
...
use NotificationChannels\Facebook\FacebookChannel;
use NotificationChannels\Facebook\FacebookMessage;
use NotificationChannels\Facebook\Components\Button;
use NotificationChannels\Facebook\Enums\NotificationType;
use Illuminate\Notifications\Notification;
class InvoicePaid extends Notification
{
public function via($notifiable)
{
return [FacebookChannel::class];
}
public function toFacebook($notifiable)
{
$url = url('/invoice/' . $this->invoice->id);
return FacebookMessage::create()
->to($notifiable->fb_messenger_user_id) // Optional
->text('One of your invoices has been paid!')
->isUpdate() // Optional
->isTypeRegular() // Optional
// Alternate method to provide the notification type.
// ->notificationType(NotificationType::REGULAR) // Optional
->buttons([
Button::create('View Invoice', $url)->isTypeWebUrl(),
Button::create('Call Us for Support!', '+1(212)555-2368')->isTypePhoneNumber(),
Button::create('Start Chatting', ['invoice_id' => $this->invoice->id])->isTypePostback() // Custom payload sent back to your server
]); // Buttons are optional as well.
}
}
return FacebookMessage::create('You have just paid your monthly fee! Thanks')
->to($notifiable->fb_messenger_user_id);
...
/**
* Route notifications for the Facebook channel.
*
* @return int
*/
public function routeNotificationForFacebook()
{
return $this->fb_messenger_user_id;
}
...
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.