1. Go to this page and download the library: Download preluigi/ontraport 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/ */
preluigi / ontraport example snippets
" "preluigi/ontraport": "dev-master"
},
$ontraport = new Ontraport\Ontraport ( 'my_app_id', 'my_app_key' );
$ontraport = new Ontraport\Ontraport ( 'my_app_id', 'my_app_key' );
$my_endpoints = array (
'object' => "my_custom_endpoint_for_single_object",
'objects' => "my_custom_endpoint_for_multiple_objects",
);
$ontraport->set_endpoint ( $my_endpoints ); // Will only change the endpoints defined in $my_endpoints
$ontraport->set_endpoint ( $my_endpoints, true ); // Will substitute all endpoints with only those defined in $my_endpoints
$ontraport = new Ontraport\Ontraport ( 'my_app_id', 'my_app_key' );
/*
* Outputs the object representing contact with id=55
*/
print_r ( $ontraport->Contacts->read ( 55 ) );
$contacts = new Ontraport\Contacts ( $ontraport );
/*
* Outputs the same object as above
*/
print_r ( $contacts->read ( 55 ) );
namespace MyNamespace; // Using a custom namespace
extends Ontraport\Contacts
*/
class Contacts extends Ontraport\Contacts {
// Overriding the parent method
public function read ( $id ) {
$result = parent::read ( $id );
// Adding the "example_field" to parent called method object result
$result->data->example_field = 'Test';
return $result;
}
}
$ontraport = new Ontraport\Ontraport ( 'my_app_id', 'my_app_key' );
$ontraport->Contacts->read ( 55 ); // Will return the Contact object with ID=55
/*
* Changing the base namespace where Ontraport\Ontraport looks for class inclusion
*/
$ontraport->set_namespace ( 'MyNamespace' );
$ontraport->Contacts->read ( 55 ); // Will return the Contact object with ID=55 and added field "example_field"
namespace MyNamespace; // Using a custom namespace
extends Ontraport\Contacts
*/
class Contacts extends Ontraport\Contacts {
// Overriding the parent method
public function read ( $id ) {
$result = parent::read ( $id );
// Adding the "example_field" to parent called method object result
$result->data->example_field = 'Test';
return $result;
}
}
$ontraport = new Ontraport\Ontraport ( 'my_app_id', 'my_app_key' );
$contacts_object = new Contacts ( $ontraport );
$contacts_object->read ( 55 ); // Will return the Contact object with ID=55 and added field "example_field"
create ( array $attrs )
get ( array $ids )
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.