PHP code example of upanupstudios / upaknee-php-client
1. Go to this page and download the library: Download upanupstudios/upaknee-php-client 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/ */
upanupstudios / upaknee-php-client example snippets
use Upanupstudios\Upaknee\Php\Client\Upaknee;
$client = Upaknee::create('YOUR_API_TOKEN', 'OPTIONAL_PASSWORD');
// Verify a token — GET /version
$client->version(); // ['message' => 'API Version: 2.1.1.3']
// The list this token belongs to — GET /subscribers/summary, then GET /lists/{id}
$list = $client->lists()->current();
$list['name']; // 'Primary Contact List'
$list['sender-name']; // 'Auto Assign QA'
$list['sender-email']; // '[email protected]'
// Or address a list directly
$client->lists()->show('1851712');
// Subscriber counts by status — GET /subscribers/summary
$client->lists()->summary(); // ['active' => '10', 'pending' => '11', 'size' => '32', …]
// Total newsletters on the account — GET /newsletters-count
$client->newsletters()->count();
// Subscriptions belonging to a newsletter — GET /newsletters/{id}/subscriptions
$subscriptions = $client->newsletters()->subscriptions('15');
$subscriptions[0]['profile-id']; // 'resubtest3'
$subscriptions[0]['name']; // 'general-communications'
$subscriptions[0]['subscription-status']; // 'active'
// Optional filters
$client->newsletters()->subscriptions('15', status: 'active', limit: 500, offset: 0);
// Just the recipients, active by default
$profileIds = $client->newsletters()->profileIds('15'); // ['resubtest3', 'resubtest5']
// Same content to many recipients — POST /triggers/{trigger-name}/mailings
$client->mailings()->submitToProfiles(
'newsletter-broadcast',
$profileIds,
['subject' => 'March update', 'body' => '<p>Hello!</p>'],
);
// Schedule it instead of sending now
$client->mailings()->submitToProfiles(
'newsletter-broadcast',
$profileIds,
['subject' => 'March update', 'body' => '<p>Hello!</p>'],
'2026-09-01T22:15:00Z',
);
// Per-recipient merge data
$client->mailings()->submit('newsletter-broadcast', [
['profile-id' => 'A', 'data' => ['first_name' => 'Ada']],
['profile-id' => 'B', 'data' => ['first_name' => 'Grace']],
]);
use Upanupstudios\Upaknee\Php\Client\XmlSerializer;
$client = new Upaknee($transport, new XmlSerializer(['body', 'html_content']));
use GuzzleHttp\Client as GuzzleClient;
use Nyholm\Psr7\Factory\Psr17Factory;
use Upanupstudios\Upaknee\Php\Client\Config;
use Upanupstudios\Upaknee\Php\Client\HttpClient;
use Upanupstudios\Upaknee\Php\Client\Upaknee;
$factory = new Psr17Factory();
$transport = new HttpClient(
new GuzzleClient(),
$factory, // PSR-17 request factory
$factory, // PSR-17 stream factory
new Config('YOUR_API_TOKEN', 'OPTIONAL_PASSWORD'),
);
$client = new Upaknee($transport);