Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broadcast message #29

Closed
vladbondarenko opened this issue Jan 2, 2018 · 3 comments
Closed

Broadcast message #29

vladbondarenko opened this issue Jan 2, 2018 · 3 comments
Assignees
Labels

Comments

@vladbondarenko
Copy link

Hi,

Is there any way to send broadcast message for all subscribers?

For example i want to trigger bot.php externaly to send all subscribers some message.

Thanks.

@Bogdaan
Copy link
Owner

Bogdaan commented Jan 3, 2018

Yes, you can.
Use this snippet:

$client = new \Viber\Client([
    'token' => 'YOU_TOKEN',
]);

$botSender = new \Viber\Api\Sender([
    'name' => 'Whois bot',
    'avatar' => 'https://developers.viber.com/img/favicon.ico',
]);

// TODO: fetch receiver ids from you database
$receiverIds = [];

foreach ($receiverIds as $id) {
      $client->sendMessage(
            (new \Viber\Api\Message\Text())
            ->setSender($botSender)
            ->setReceiver($receiverId)
            ->setText('text message here')
        );
}

@Bogdaan Bogdaan closed this as completed Jan 3, 2018
@Bogdaan Bogdaan self-assigned this Jan 3, 2018
@vladbondarenko
Copy link
Author

Yes, got you. But is there any way to make a viber call instead of message? Tried to google but nothing found.

@Bogdaan
Copy link
Owner

Bogdaan commented Jan 16, 2018

As far as I know, calls via PA-api not supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants