1. Go to this page and download the library: Download nocksapp/nocks-sdk-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nocksapp / nocks-sdk-php example snippets
use Nocks\SDK\NocksOauth;
use Nocks\SDK\Constant\Platform;
try {
$clientId = '1';
$clientSecret = '1234';
$scopes = ['user.read'];
$redirectUri = 'https://www.example.com';
$nocksOauth = new NocksOauth(Platform::SANDBOX, $clientId, $clientSecret, $scopes, $redirectUri);
$uri = $nocksOauth->getOauthUri();
// For example, redirect the user to the Nocks login page
header('Location: ' . $uri);
die();
} catch (\Nocks\SDK\Exception\Exception $e) {
// Handle any SDK exception
}
use Nocks\SDK\NocksApi;
use Nocks\SDK\Constant\Platform;
try {
$accessToken = 'your_access_token';
$nocksApi = new NocksApi(Platform::SANDBOX, $accessToken);
$user = $nocksApi->user->findAuthenticated();
} catch (\Nocks\SDK\Exception\Exception $e) {
// Handle any SDK exception
}
use Nocks\SDK\NocksApi;
use Nocks\SDK\Constant\Platform;
try {
$accessToken = 'your_access_token';
$nocksApi = new NocksApi(Platform::SANDBOX, $accessToken);
$result = $nocksApi->transaction->find();
$result->getPagination(); // Do something with pagination
// Loop through transactions
foreach ($result->getData() as $transaction) {
// Do something with the transaction
}
} catch (\Nocks\SDK\Exception\Exception $e) {
// Handle any SDK exception
}
use Nocks\SDK\NocksApi;
use Nocks\SDK\Constant\Platform;
try {
$accessToken = 'your_access_token';
$nocksApi = new NocksApi(Platform::SANDBOX, $accessToken);
$userToUpdate = new User();
// $userToUpdate->setUuid('1234'); Will occur in an exception when not set
$user = $nocksApi->user->update($userToUpdate);
} catch (\Nocks\SDK\Exception\ValidationException $e) {
// A ValidationException will be thrown when the $userToUpdate has no uuid
}
use Nocks\SDK\NocksApi;
use Nocks\SDK\Constant\Platform;
try {
$accessToken = null;
$nocksApi = new NocksApi(Platform::SANDBOX, $accessToken);
$userToUpdate = new User([
'uuid' => '1234',
'locale' => 'nl_NL',
]);
$user = $nocksApi->user->update($userToUpdate);
} catch (\Nocks\SDK\Exception\ScopeConfigurationException $e) {
// A ScopeConfigurationException will be thrown when the $accessToken is null
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.