This is our PHP client library for accessing the Subscribe Pro REST API. Our API documentation is available at https://docs.subscribepro.com/technical/rest-api/.
To learn more about Subscribe Pro you can visit us at https://www.subscribepro.com/.
You can install our PHP client via Composer. Run the following command:
composer require subscribepro/subscribepro-php
To use the PHP client, use Composer's autoload:
require_once('vendor/autoload.php');
With php-cs-fixer
v3.x installed, run this in project folder:
php-cs-fixer fix
With dev dependencies installed via composer (these will install phpunit >= 9.5), run this:
vendor/bin/phpunit
Simple usage looks like (example fetching a list of products):
<?php
use SubscribePro\Sdk;
// Set credentials
$clientId = 'XXXX';
$clientSecret = 'XXXX';
// Set log message format
$messageFormat = "SUBSCRIBE PRO REST API Call: {method} - {uri}\nRequest body: {req_body}\n{code} {phrase}\nResponse body: {res_body}\n{error}\n";
// Create SDK object
// Setup with Platform API base url and credentials from Magento config
$sdk = new Sdk([
'client_id' => $clientId,
'client_secret' => $clientSecret,
'logging_enable' => true,
'logging_file_name' => 'var/log/subscribe_pro_api.log',
'logging_message_format' => $messageFormat,
'api_request_timeout' => 60,
]);
$products = $sdk
->getProductService()
->loadProducts(['sku' => 'SOME-EXAMPLE-SKU']);