madewithlove / facebook-messenger-platform
Easily communicate with the facebook messenger platform
Requires
- php: >=5.5.9
- guzzlehttp/guzzle: ^6.2
Requires (Dev)
- fabpot/php-cs-fixer: 2.0.*@dev
- mockery/mockery: ^0.9.4
- phpspec/phpspec: ^2.2
- phpunit/phpunit: ^4.7
- symfony/var-dumper: ^2.7
This package is auto-updated.
Last update: 2019-11-15 15:26:27 UTC
README
A set of helpers to communicate with the Facebook Messenger Platform
Goals
Install
Via Composer
$ composer require madewithlove/facebook-messenger-platform
Usage
Creating a client
This package assumes you have followed the getting started guide and have received an access token for the Facebook page.
use Madewithlove\FacebookMessengerPlatform\Api\HttpClient; use Madewithlove\FacebookMessengerPlatform\Api\Client; $httpClient = new HttpClient('your_access_token'); $client = new Client($httpClient);
Sending Messages
Text
$client->send()->message('recipient_id', 'hello world');
Image
$client->send()->image('recipient_id', 'http://url-to-image.com');
Generic Template
Takes the recipient ID and an array of elements. Refer to the documentation for what the elements can consist of.
$client->send()->generic('recipient_id', []);
Buttons Template
Takes the recipient ID, an array of buttons and a text. Refer to the documentation for what the elements can consist of.
$client->send()->buttons('recipient_id', []);
Receipt Template
Takes the recipient ID and an payload for the receipt. Refer to the documentation for what the receipt can consist of.
$client->send()->buttons('recipient_id', []);
TODO
- Welcome message configuration
- User Profile
Testing
$ composer test
License
The MIT License (MIT). Please see License File for more information.