perkora / php-sdk
Official PHP SDK for integrating external applications with Perkora.
Requires
- php: ^8.2
- ext-curl: *
- ext-hash: *
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^12.5
Suggests
- illuminate/support: Required when using the Laravel service provider.
Provides
None
Conflicts
None
Replaces
None
README
Official PHP SDK for connecting external applications to Perkora.
Current version: 1.0.0
Features
- Plain PHP integration.
- Laravel integration through Composer.
- HMAC-SHA256 request authentication.
- Perkora account linking.
- Offer retrieval.
- Automatic completion reporting.
- Completion status lookup.
- Automatic wallet reward processing by Perkora.
Requirements
- PHP 8.2 or newer.
- PHP cURL extension.
- PHP JSON extension.
- PHP Hash extension.
Installation with Composer
The package is currently distributed through GitHub.
Add this repository configuration to your application's composer.json:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/popevibe-dot/perkora-php-sdk"
}
],
"require": {
"perkora/php-sdk": "^1.0"
}
}
Then run:
composer update perkora/php-sdk
Once the package is registered on Packagist, the repository configuration will no longer be necessary.
Laravel Installation
The Laravel service provider is automatically discovered by Laravel.
Publish the configuration:
php artisan vendor:publish --tag=perkora-config
Add these variables to your .env file:
PERKORA_BASE_URL=https://your-perkora-domain.com PERKORA_KEY_ID=your_api_key_id PERKORA_SECRET=your_api_secret PERKORA_TIMEOUT=20
Resolve the client through Laravel:
$perkora = app('perkora'); $offers = $perkora->getOffers();
Or use the facade:
use Perkora\SDK\Laravel\Perkora; $offers = Perkora::getOffers();
Standalone Installation (Without Composer)
The standalone installer downloads the SDK directly from GitHub and creates a PSR-4 autoloader.
Requirements:
- PHP 8.2 or newer.
- PHP cURL extension.
- PHP ZipArchive extension.
First, download the installer:
curl -L https://raw.githubusercontent.com/popevibe-dot/perkora-php-sdk/v1.0.0/installer/install.php -o install.php
Run it from your project directory:
php install.php popevibe-dot/perkora-php-sdk v1.0.0
The SDK will be installed into:
vendor/perkora/php-sdk/
Load the SDK:
require_once __DIR__ . '/vendor/perkora/php-sdk/autoload.php'; use Perkora\SDK\PerkoraClient; $perkora = PerkoraClient::create( getenv('PERKORA_BASE_URL'), getenv('PERKORA_KEY_ID'), getenv('PERKORA_SECRET') );
You can also specify a different installation directory:
php install.php popevibe-dot/perkora-php-sdk v1.0.0 /path/to/project
Plain PHP Usage
If you installed through Composer, load Composer's autoloader:
require_once __DIR__ . '/vendor/autoload.php'; use Perkora\SDK\PerkoraClient; $perkora = PerkoraClient::create( getenv('PERKORA_BASE_URL'), getenv('PERKORA_KEY_ID'), getenv('PERKORA_SECRET') );
If you used the standalone installer, use its autoloader instead.
Available Methods
Link an account
$result = $perkora->linkAccount( $linkCode, $externalUserId );
Retrieve available offers
$result = $perkora->getOffers();
Report a completed offer
$result = $perkora->completeOffer( $externalEventId, $externalUserId, $externalOfferId, ['source' => 'your-application'] );
Check completion status
$result = $perkora->getCompletionStatus( $externalEventId );
Important Integration Rules
- Your project must be approved and registered by the Perkora administrator before API credentials can be issued.
- Keep your API secret private. Never expose it in frontend JavaScript or public application code.
- Each external user must link their account to Perkora before completing offers.
- Your application must generate a unique external event ID for every completion event.
- Perkora determines the reward amount. External applications must never submit or control reward amounts.
- Successful verified completions are credited automatically to the linked Perkora user's wallet.
- Repeating the same completion event is protected by idempotency.
Error Handling
API errors are represented by PerkoraApiException.
use Perkora\SDK\Exceptions\PerkoraApiException; try { $offers = $perkora->getOffers(); } catch (PerkoraApiException $exception) { echo $exception->getMessage(); echo $exception->getHttpStatus(); }
Versioning
Releases are published on GitHub: