PHP code example of ka4ivan / laravel-notification-channel-instagram

1. Go to this page and download the library: Download ka4ivan/laravel-notification-channel-instagram 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/ */

    

ka4ivan / laravel-notification-channel-instagram example snippets


// config/services.php
'instagram' => [
    'api_version' => env('INSTAGRAM_API_VERSION', '22.0'),
    'access_token' => env('INSTAGRAM_ACCESS_TOKEN', ''),
    'profile_id' => env('INSTAGRAM_PROFILE_ID', ''),
    'start_buttons' => [
        [
            'question' => 'Start',
            'payload' => 'start',
        ],
    ],
],

{--access_token= : Instagram access token}
{--profile_id= : Instagram profile ID}
{--api_version= : Instagram API version (default from config)}'

use NotificationChannels\Instagram\InstagramChannel;
use NotificationChannels\Instagram\InstagramMessage;

use Illuminate\Notifications\Notification;

class ChannelConnected extends Notification
{
    public function via($notifiable)
    {
        return [InstagramChannel::class];
    }

    public function toInstagram($notifiable)
    {

        return InstagramMessage::create()
            ->to($notifiable->instagram_id) // Optional
            ->text('Congratulations, the communication channel is connected');
    }
}

return InstagramMessage::create('You have just paid your monthly fee! Thanks');

return InstagramMessage::create()
    ->attach(AttachmentType::IMAGE, url('images/'.$this->product->id))
    ->to($notifiable->instagram_id);

return InstagramMessage::create()
    ->to($notifiable->instagram_id)
    ->text('How can we help?')
    ->buttons([
        Button::create('View Website', $url)->isTypeWebUrl(),
        Button::create('Start Chatting', ['user' => $this->user->id])->isTypePostback() // Custom payload sent back to your server
    ]);

/**
 * Route notifications for the Instagram channel.
 *
 * @return int
 */
public function routeNotificationForInstagram()
{
    return $this->instagram_id;
}
 bash
php artisan instagram:set-start-buttons