bfg / snelstart-php
Snelstart API toegepast in PHP
Requires
- php: >=7.2
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^6.3|7.*
- moneyphp/money: ^3.0|^4.0
- myclabs/php-enum: ^1.6
- psr/cache: ^1|^2|^3
- psr/http-message: ^1.0
- psr/log: ^1.0|^2.0|^3.0
- ramsey/uuid: ^3.8|^4.0
Requires (Dev)
- dg/bypass-finals: ^1.1
- phpstan/phpstan: ^1.5
- phpunit/phpunit: ^8.4
- vimeo/psalm: ^4.0
Suggests
- psr/cache: Caching made a little easier. Useful for access tokens.
This package is not auto-updated.
Last update: 2024-11-14 12:29:41 UTC
README
PHP client library to use the Snelstart B2B API.
Note that this library is not created, or maintained, by Snelstart.
Pre-word
This release will support both version 1 and version 2. Version 1 is considered deprecated, as Snelstart does not activly promote it anymore. Instructions on how to upgrade will be added when the next release takes place.
Installation
Installation is easy as 1, 2, 3 thanks to Composer.
composer require bfg/snelstart-php
Usage
Create an account at [https://b2bapi-developer.snelstart.nl/] and subscribe to 'Verkenning'. Obtain the Primary and Secondary key from your Profile and generate a key on the web interface of Snelstart under 'Maatwerk'. You are going to need these credentials for the next chapter.
Authentication
Now that you have obtained the credentials you can start by connection the library to the API.
$primaryKey = "<primary>"; $secondaryKey = "<secondary>"; $clientKey = "<maatwerksleutel>"; $bearerToken = new \SnelstartPHP\Secure\BearerToken\ClientKeyBearerToken($clientKey); $accessTokenConnection = new \SnelstartPHP\Secure\AccessTokenConnection($bearerToken); $accessToken = $accessTokenConnection->getToken(); $connection = new \SnelstartPHP\Secure\V2Connector( new \SnelstartPHP\Secure\ApiSubscriptionKey($primaryKey, $secondaryKey), $accessToken );
_Please note that there is also a class named SnelstartPHP\Secure\CachedAccessTokenConnection
for when you are done with developing. This will automatically take care of renewing expired access tokens. _
Check if you are really authenticated
We implemented the EchoConnector
to test to see if you are authenticated.
Fetch data
For an example see var/doc/v2/inkoopboeking_find_all.php
Add data
For an example see var/doc/v2/inkoopboeking_add.php
Supported resources
Not all resources are currently implemented. Feel free to create a pull request.