PHP code example of kzap / ontraport-php-sdk

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

    

kzap / ontraport-php-sdk example snippets



	

use Kzap\Ontraport\Api\Sdk as OntraportSdk;
	

$this->ontraportSdk = new OntraportSdk("{APP_ID}", "{API_KEY}");
	

$parameters = array(
	'objectId' => $this->ontraportSdk->getObjectTypeByName('contact'),
);
$jsonResponse = $this->ontraportSdk->getObject($parameters);
var_dump($jsonResponse);
    



namespace App;

use Kzap\Ontraport\Api\Sdk as OntraportSdk;

--------*/
    private $ontraportSdk = null;
    
    public function __construct($appId, $apiKey)
    {
        $this->ontraportSdk = new OntraportSdk($appId, $apiKey);
    }
    
    public function getContacts()
    {
        $parameters = array(
            'objectId' => $this->ontraportSdk->getObjectTypeByName('contact'),
        );
        $jsonResponse = $this->ontraportSdk->getObject($parameters);
        
        return $jsonResponse;
    }
}

$ontraportApp = new OntraportApp("APP_ID", "API_KEY");
$contacts = $ontraportApp->getContacts();
var_dump($contacts);