PHP code example of effectconnect / php-sdk

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

    

effectconnect / php-sdk example snippets


    

    use EffectConnect\PHPSdk\Core\Helper\Keychain;
    use EffectConnect\PHPSdk\Core;
    
    $keychain  = (new Keychain())
        ->setPublicKey('YourPublicKey')
        ->setSecretKey('YourSecretKey')
    ;
    // Instantiate the API Core
    $core = new Core($keychain);

    $orderCall = $core->OrderCall();

    use EffectConnect\PHPSdk\Core\Model\Request\OrderReadRequest;
    $orderReadRequest = (new OrderReadRequest())
        ->setIdentifierType(OrderReadRequest::TYPE_EFFECTCONNECT_NUMBER)
        ->setIdentifier('EC-ORDER-ID')
    ;
    $apiCall = $orderCall->read($orderReadRequest);

    $apiCall->call();

    if (!$apiCall->isSuccess()) 
    {
        // Check $apiCall->getErrors() for errors that have occurred.
    }

    // The EffectConnect\PHPSdk\Core\Model\Response\ApiResponseContainer
    $responseContainer = $apiCall->getResponseContainer();
    // The EffectConnect\PHPSdk\Core\Model\Response\Response
    $response          = $responseContainer->getResponse();
    if ($response->getResult() === Response::STATUS_SUCCESS)
    {
        // The EffectConnect\PHPSdk\Core\Model\Response\OrderReadResponseContainer
        $orderResponse = $response->getResponseContainer();
        // Our EffectConnect\PHPSdk\Core\Model\Response\Order
        $order         = $orderResponse->getOrder();
        echo '<pre>';
        print_r($order->getIdentifiers());
        echo '</pre>';
    }

    composer