Simple library to quickly implement a N4B Be-App PHP backend
N4B PHP will allow you to concentrate your development only on your business domain. Authentication, operations dispatching, N4B Errors, formatting of the responses are handled by the library.
Be-Bound's N4B platform helps you develop Android applications with the possibility to reach the Next 4 Billion (N4B) users that are still not connected to the Internet. By integrating Be-Bound’s SDK into your Android apps, and implementing your Be-App Webhooks, your users will stay connected to your apps even when there is no internet.
N4B PHP works with PHP 5.6.0 or newer.
It's recommended that you use Composer to install N4B PHP.
$ composer require n4b/n4b
This will install N4B PHP and all required dependencies.
Create an index.php file with the following contents:
<?php
require 'vendor/autoload.php';
$n4b = new N4B\Webhook('mybeapp', 1337, 1, 'MY5UP3r53Cr37K3Y');
$n4b->add('myOperation', function($params, $transport, $userId) {
return ['uppercaseString' => strtoupper($params['someString'])];
});
$n4b->run();
You may quickly test this using the built-in PHP server:
$ php -S localhost:8000
Then running the cURL POST request below (or use the Postman button) will now return a well formated N4B response "{"params":["uppercaseString","THIS VERY INTERESTING TEXT WILL BE OUTPUT IN UPPERCASE"]}".
curl --request POST \
--url http://localhost:8000/ \
--header 'authorization: Basic bXliZWFwcF8xMzM3Ok1ZNVVQM3I1M0NyMzdLM1k=' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"transport":"web","userId":"98e866b2-3d39-11e6-97dc-0cc47a77819c","moduleId":1337,"moduleName":"mybeapp","moduleVersion":1,"operation":"myOperation","params":{"someString":"this very interesting text will be output in uppercase"}}'
Please see CHANGELOG for more information what has changed recently.
$ composer test
Bugs and feature request are tracked on GitHub
If you discover any security related issues, please email lbrianto@be-bound.com instead of using the issue tracker.
Lionel Brianto - lbrianto@be-bound.com - http://twitter.com/kinobiweb
N4B PHP is licensed under the MIT License - see the LICENSE
file for details