PHP code example of pigeonboys / fastpush

1. Go to this page and download the library: Download pigeonboys/fastpush 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/ */

    

pigeonboys / fastpush example snippets


use PigeonBoys\Fastpush\Client\PushConfiguration;

PushConfiguration::initialize(
    host: 'https://example.com/api/push',
    token: '<bearer-token>'
);

use Fastpush\Client\PushClient;
use Fastpush\Entity\Channel;
use Fastpush\Entity\Message;
use Fastpush\Entity\Topic;

$channel = new Channel(
    externalId: 'channel.test',
    name: 'Test Channel',
    imageUrl: 'https://example.com/images/test.png'
);

$topic = new Topic(
    externalId: 'topic.test',
    name: 'Test Topic',
    category: 0
);

$messages = [
    new Message(
        recipients: [100100, 100200],
        content: 'Hey Folks! That is a test message for 100100 and 100200.',
        attachments: [
            'https://cdn.example.com/100100.pdf',
            'https://cdn.example.com/100200.pdf'
        ],
    ),
    new Message(
        recipients: [100300, 100400],
        content: 'Hey Folks! That is a test message for 100300 and 100400.',
        attachments: [
            'https://cdn.example.com/100300.pdf',
            'https://cdn.example.com/100400.pdf'
        ],
    )
];

$res = PushClient::send(
    channel: $channel,
    topic: $topic,
    messages: $messages
);