PHPackages                             fritak/nette-messenger-platform - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. fritak/nette-messenger-platform

ActiveLibrary

fritak/nette-messenger-platform
===============================

Facebook Messenger Platform PHP API for bots.

v1.0.0(10y ago)129MITPHPPHP &gt;=5.4.0

Since Apr 20Pushed 10y ago1 watchersCompare

[ Source](https://github.com/Fritak/nette-messenger-platform)[ Packagist](https://packagist.org/packages/fritak/nette-messenger-platform)[ Docs](https://github.com/fritak/nette-messenger-platform)[ RSS](/packages/fritak-nette-messenger-platform/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Facebook Messenger Platform PHP API for bots in nette.
======================================================

[](#facebook-messenger-platform-php-api-for-bots-in-nette)

This code is an implementation of the Messenger Platform in a PHP for nette.

INSTALLATION
------------

[](#installation)

```
composer require "fritak/nette-messenger-platform"

```

REQUIREMENTS
------------

[](#requirements)

The minimum requirement is PHP 5.4 on your Web Server.

SETUP
-----

[](#setup)

Add the following to the config.neon:

```
parameters:
	messenger:
		accessTokens:
				page1: 'TOKEN'
				page2: 'TOKEN'
				page3: 'TOKEN'
		defaultToken: 'page2' # optional, default is first
		webhookToken: 'WEBHOOK'
		facebookApiUrl: 'https://graph.facebook.com/v2.6/me/' #2.6 is minimum
services:
	- fritak\NetteMessengerPlatform(%messenger%)
```

Then you can use the component in the presenter:

```
    public $bot;

    public function __construct(\fritak\NetteMessengerPlatform $bot)
    {
        $this->bot = $bot;
        parent::__construct();
    }

    public function actionDefault()
    {
        if($this->bot->checkSubscribe())
        {
            print $this->bot->request->getChallenge();
            $this->terminate();
        }

        $this->bot->subscribe();

        $this->bot->setToken('page3');

        $messages = $this->bot->getMessagesReceived();
        \Tracy\Debugger::log($messages);

        $this->bot->subscribe();
    }
```

BASIC USAGE
-----------

[](#basic-usage)

```
// Check if request is subscribe and then return challenge - [documentation](https://developers.facebook.com/docs/messenger-platform/implementation#setup_webhook)
if($bot->checkSubscribe())
{
    print $bot->request->getChallenge();
    exit;
}

// Subscribe the App to a Page. In order for your webhook to receive events for a specific page, you must subscribe your app to the page.
$bot->subscribe();
```

GETTING MESSAGES
----------------

[](#getting-messages)

```
// Messenger is calling your URL, someone is sending a message...
$messages = $bot->getMessagesReceived();
```

SENDING MESSAGES
----------------

[](#sending-messages)

```
// Send a simple text message.
$bot->sendMessage($userToSendMessage, 'Example!');

// Send an image (file).
$bot->sendImage($userToSendMessage, 'http://placehold.it/150x150');

// Send a structured Message - button template.
$buttons = [new Button('Click', Button::TYPE_WEB, 'example.com'), new Button('Click2', Button::TYPE_POSTBACK, 'example.com')];
$bot->sendButton($userToSendMessage, 'Example text... Not too long, hehe.', $buttons);

// Send a structured Message - receipt template.
$elements    = [new ReceiptElement(['title' => 'Panda', 'price' => 9.99]), new ReceiptElement(['title' => 'Bunny', 'price' => 9.99])];
$summary     = new Summary(['total_cost' => 17.98]);
$address     = new Address(['street_1' => 'Queens 1', 'city' => 'Example city', 'postal_code' => '10000', 'state' => 'DO', 'country' => 'CZ']);
$receipt     = new Receipt('User', Rand(1,9999), 'USD', 'card', $elements, $summary, $address, $adjustments, time(), 'example.com');
$adjustments = [new Adjustment(['name' => 'Discount', 'amount' => 2])];

$bot->sendReceipt($userToSendMessage, $receipt);
```

SENDING MESSAGES WITH StructuredMessage
---------------------------------------

[](#sending-messages-with-structuredmessage)

```
$bot->sendComplexMessage(new StructuredMessage($userToSendMessage,
                ['url' => 'http://placehold.it/150x150'],
                MessageSend::NOTIFICATION_TYPE_SILENT_PUSH,
                StructuredMessage::ATTACHMENT_TYPE_IMAGE));

$bot->sendComplexMeesage(new StructuredMessage($userToSendMessage,
                [new Element('Example.', 'Example...', 'http://placehold.it/150x150', 'http://placehold.it/150x150', [new Button('Click', Button::TYPE_WEB, 'example.com')])],
                MessageSend::NOTIFICATION_TYPE_SILENT_PUSH,
                StructuredMessage::ATTACHMENT_TYPE_TEMPLATE,
                StructuredMessage::TEMPLATE_PAYLOAD_TYPE_GENERIC));

$bot->sendComplexMeesage(new StructuredMessage($userToSendMessage,
                ['text' => 'Example text... Not too long, hehe.',
                 'buttons' => [new Button('Click', Button::TYPE_WEB, 'example.com'), new Button('Click2', Button::TYPE_POSTBACK, 'example.com')]],
                MessageSend::NOTIFICATION_TYPE_SILENT_PUSH,
                StructuredMessage::ATTACHMENT_TYPE_TEMPLATE,
                StructuredMessage::TEMPLATE_PAYLOAD_TYPE_BUTTON));
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3673d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/283db6980ccd8ad835cb896ad037c7bd64bcd2d159593ccab02f900a2754acbf?d=identicon)[Fritak](/maintainers/Fritak)

---

Top Contributors

[![Fritak](https://avatars.githubusercontent.com/u/9657317?v=4)](https://github.com/Fritak "Fritak (2 commits)")

### Embed Badge

![Health badge](/badges/fritak-nette-messenger-platform/health.svg)

```
[![Health](https://phpackages.com/badges/fritak-nette-messenger-platform/health.svg)](https://phpackages.com/packages/fritak-nette-messenger-platform)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
