Our PHP-SDK provides a simple interface for PHP developers to integrate Quentn into their application. Features include:
- Easy installation of all dependencies with Composer
- Build in functions for each API-Endpoint
- Helper functions to get started with Oauth 2.0 authentication
Please visit our Github Repository for more information.
Install the SDK
We highly recommend composer to install the Quentn-PHP-SDK. To learn more about composer please visit the Composer Getting Started Guide.
To install the Quentn-PHP-SDK with composer, simple run:
composer require quentn/php-sdk
You can also manually add the dependency to your composer.json file:
{
"require": {
"quentn/php-sdk": "1.0.*"
}
}
Examples
Autoload
Add autoload on top of each file:
require __DIR__ . './vendor/autoload.php';
Create a new contact
This example shows how to create a new contact.
require __DIR__ . './vendor/autoload.php';
$quentn = new Quentn\Quentn([
'api_key' => 'API_KEY',
'base_url' => 'BASE_URL',
]);
//check API key
if (!$quentn->test()) {
echo "key doesn't seem to work";
exit;
}
//create contact
$data = [
"first_name" => "Johnn",
"family_name" => "Doe",
"mail" => "johndoe@example.com",
];
try {
$get_response = $quentn->contacts()->createContact($data);
$contact_id = $get_response['data']['id'];
} catch (Exception $e) {
echo $e->getMessage();
}
Oauth Authentication
With Oauth authentication you are able to get the API url and API key from a target system automatically. The end user only has to confirm your app with one click.
To register an app with Quentn, you require a Quentn Developer Account. Please email us at info@quentn.com (or submit a ticket) to request a developer account.
To start the OAuth process, you need to register your application with Quentn. After registration you will receive your Client ID and Client Secret.
require __DIR__ . './vendor/autoload.php';
$quentn = new Quentn\Quentn();
$quentn->oauth()->setApp([
'client_id' => 'CLIENT_ID',
'client_secret' => 'CLIENT_SECRET',
'redirect_uri' => 'REDIRECT_URL',
]);
if($quentn->oauth()->authorize()) {
/*
do you stuff here
You can now access your App key and base url with:
$quentn->getApiKey();
$quentn->getBaseUrl();
*/
try {
$get_response = $quentn->contacts()->findContactById($contactId, 'first_name, mail');
} catch (Exception $e) {
echo $e->getMessage();
}
}
else {
// to get the Authorization URL you can use getAuthorizationUrl() function
echo '<a href="' . $quentn->oauth()->getAuthorizationUrl() . '">Click here to get authorize</a>';
}