PHP code example of toktokdev / printapi-sdk

1. Go to this page and download the library: Download toktokdev/printapi-sdk 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/ */

    

toktokdev / printapi-sdk example snippets


use PrintAPI\PrintAPI;
  
// 1. Initialize the API client
$api = new PrintApi(
    clientId: 'your_client_id',
    clientSecret: 'your_client_secret',
    testMode: true // Use test environment
);

// 2. Create an access token authenticator

$authenticator = $api->getAccessToken();

// 3. Authenticate the connector

$api->authenticate($authenticator);


// Place an order
$order = $api->orders()->create($orderData);

// Get a single order
$order = $api->orders()->get('order_id');

// Get order status
$status = $api->orders()->getStatus('order_id');

// List orders (with pagination)
$orders = $api->orders()->list();

// Get status updates since date
$updates = $api->orders()->getStatusUpdates($since);


// List all products
$products = $api->products()->list();

// Get single product
$product = $api->products()->get('product_id');


// Get shipping quote
$quote = $api->shipping()->getQuote($quoteRequest);