PHP code example of wpcs / php-api-wrapper

1. Go to this page and download the library: Download wpcs/php-api-wrapper 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/ */

    

wpcs / php-api-wrapper example snippets


$request = new \WPCS\API\GetTenantsRequest();
$response = $request
    ->setRegion('us1') // Or eu1, depending on your region.
    ->setApiKey('an-api-key') // The API Key you retrieved from the console
    ->setApiSecret('an-api-secret') // The API Secret you retrieved from the console
    ->send();

define('WPCS_API_REGION', 'us1'); // Or eu1, depending on your region.
define('WPCS_API_KEY', 'an-api-key'); // The API Key you retrieved from the console
define('WPCS_API_SECRET', 'an-api-secret'); // The API Secret you retrieved from the console

// No need to set the region, API key and secret using functions now
$request = new \WPCS\API\GetTenantsRequest();
$response = $request->send();

$request = new \WPCS\API\CreateVersionRequest();
$response = $request
    ->setRegion('us1')
    ->setApiKey('an-api-key')
    ->setApiSecret('an-api-secret')
    ->setName('v2.0.0')
    ->setWordPressVersion('6.0')
    ->setPhpVersion('7.4')
    ->send();