Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mesilov/yandex-dialogs-php-sdk
PHP-библиотека для облегчения работы с диалогами от Яндекс
https://github.com/mesilov/yandex-dialogs-php-sdk
alice alice-sdk alice-skills alisa php sdk yandex yandex-alisa yandex-dialogs
Last synced: 3 days ago
JSON representation
PHP-библиотека для облегчения работы с диалогами от Яндекс
- Host: GitHub
- URL: https://github.com/mesilov/yandex-dialogs-php-sdk
- Owner: mesilov
- License: mit
- Created: 2018-03-13T21:22:53.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-08T20:08:16.000Z (over 6 years ago)
- Last Synced: 2024-12-02T22:35:12.471Z (20 days ago)
- Topics: alice, alice-sdk, alice-skills, alisa, php, sdk, yandex, yandex-alisa, yandex-dialogs
- Language: PHP
- Homepage: https://alice-skills.ru/
- Size: 11.7 KB
- Stars: 26
- Watchers: 5
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-alice - mesilov/yandex-dialogs-php-sdk
README
# yandex-dialogs-php-sdk
Репозиторий PHP-библиотеки для облегчения работы с диалогами## Пример использования
```php
// получаем входящий API-запрос
$apiRequestArray = json_decode(trim(file_get_contents('php://input')), true);$dialogRequest = Yandex\Dialogs\Webhook\Request\Fabric::initFromArray($apiRequestArray);
$responseFabric = new Yandex\Dialogs\Webhook\Response\Fabric($dialogRequest);$button1 = new Yandex\Dialogs\Webhook\Response\DTO\Buttons\Button();
$button1
->setTitle('Кнопка1')
->setUrl('https://ya.ru');$button2 = new Yandex\Dialogs\Webhook\Response\DTO\Buttons\Button();
$button2
->setTitle('Кнопка2');$response = $responseFabric
->setText('Привет')
->setTts('Привет')
->addButton($button1)
->addButton($button2)
->buildResponse();header('Content-Type: application/json');
print(json_encode(Yandex\Dialogs\Webhook\Response\Formatters\Formatter::toArray($response), JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT));
```