journy-io / sdk
This is the official PHP SDK for journy.io
Installs: 6 246
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: ^7.0 || ^8.0
- composer-runtime-api: ^2.1
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
Requires (Dev)
- kriswallsmith/buzz: ^1.2
- nyholm/psr7: ^1.3
- phpunit/phpunit: >=8.0
- squizlabs/php_codesniffer: ^3.0
Suggests
- kriswallsmith/buzz: PSR-18 HTTP client
- nyholm/psr7: PSR-7 and PSR-17 implementation
README
journy.io PHP SDK
This is the official PHP SDK for journy.io.
πΎ Installation
You can use composer to install the SDK:
composer require journy-io/sdk
You will also need a PSR-7 implementation (HTTP messages), PSR-17 implementation (HTTP factory) and PSR-18 implementation (HTTP client).
If your app doesn't have these yet installed, we recommend:
composer require kriswallsmith/buzz nyholm/psr7
π Getting started
Configuration
To be able to use the SDK you need to generate an API key. If you don't have one you can create one in journy.io.
If you don't have an account yet, you can create one in journy.io or request a demo first.
Go to your settings, under the Connections-tab, to create and edit API keys. Make sure to give the correct permissions to the API Key.
use JournyIO\SDK\Client; // composer require kriswallsmith/buzz nyholm/psr7 $client = Client::withDefaults("your-api-key");
If you want to use your own HTTP client (PSR-18):
use Buzz\Client\Curl; use JournyIO\SDK\Client; use Nyholm\Psr7\Factory\Psr17Factory; // https://github.com/Nyholm/psr7 $factory = new Psr17Factory(); // https://github.com/kriswallsmith/Buzz $http = new Curl($factory, ["timeout" => 5]); $client = new Client($http, $factory, $factory, ["apiKey" => "your-api-key"]);
Methods
Get API key details
use JournyIO\SDK\ApiKeyDetails; $call = $client->getApiKeyDetails(); if ($call->succeeded()) { $result = $call->result(); if ($result instanceof ApiKeyDetails) { var_dump($result->getPermissions()); // string[] } } else { var_dump($call->errors()); }
Handling errors
Every call will return a result, we don't throw errors when a call fails. We don't want to break your application when things go wrong. An exception will be thrown for required arguments that are empty or missing.
$call = $client->getTrackingSnippet("blog.acme.com"); var_dump($call->succeeded()); // bool var_dump($call->rateLimited()); // bool var_dump($call->remainingRequests()); // int var_dump($call->maxRequests()); // int var_dump($call->errors()); // array
π¬ API Docs
π― Tests
To run the tests:
composer run test
β Help
We welcome your feedback, ideas and suggestions. We really want to make your life easier, so if weβre falling short or should be doing something different, we want to hear about it.
Please create an issue or contact us via the chat on our website.
π Security
If you discover any security related issues, please email security at journy io instead of using the issue tracker.