< back
PHP examples
Authentication
General Barnes Data Authentication uses a Single Sign On (SSO) solution (FusionAuth) : you need first to be authenticated before getting an access token for your app.
This example uses Composer to load the following libraries :
- FusionAuth PHP client : FusionAuth API client (More infos) ;
- Carbon : A Datetime extension (More infos) ;
- Symfony Dotenv : Component loading ENV variables (More infos) ;
Example #1
Objective : Perform Graphql queries to Barnes Data API.
Specific files composing this example :
- - .env : files with ENV custom variables, and more specifically your personnal authentication informations.
- - php/env.php : load custom ENV variables + define fixed ENV php constants + vendor autoload (composer).
- - php/example_1/index.php (entry point) : A console allow you to perform requests manually to Barnes Data API.
- - php/example_1/login.php : functions to perform the authentication process with "FusionAuth PHP client".
- - php/example_1/GQLClient.php : A light GraphQL requests manager ;
Test this example : example_1/index.php.
Example #2
Objective : Perform Graphql subscription to Barnes Data API events, and listen them with SSE.
Specific files composing this example :
- - .env : files with ENV custom variables, and more specifically your personnal authentication informations.
- - php/env.php : load custom ENV variables + define fixed ENV php constants + vendor autoload (composer).
- - logs/events.log : this file is created automatically and contains results returned by API (displayed in iframe).
- - php/example_2/index.php (entry point) : An alternative request method to subscribe to Barnes Data API events.
- - php/example_2/SSEClient.php : Script listening events thanks of a Symfony ServerSentEvent library.
- - php/example_2/login.php : functions to perform the authentication process with "FusionAuth PHP client".
- - php/example_2/GQLClient.php : A light GraphQL requests manager ;
Be careful : this example needs that 'write/read' rights being set on '/logs' folder.
Test this example : example_2/index.php.