PHP code example of jrbarnard / efapiwrap

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

    

jrbarnard / efapiwrap example snippets


// Define a new client, passing in the client slug and api key
$client = new \EventsForce\Client('apiexample', '035E0A65508A4D8FAB63A983F36ACCAC');

$stream = $client->events->getAll();

$client->events->getAll();

$client->events->get(2); // where 2 is the event id

$client->attendees
    ->setEvent(2)
    ->getAll();

// Or you can also pass arguments where it is a key value array as below
$arguments = [
    'lastModifiedAfter' => '2016-04-07 19:43:26', // date('Y-m-d H:i:s');
    'paymentStatus' => 'paid',
    'category' => 'Attendee',
    'registrationStatus' => 'complete'
];

$client->attendees
    ->getAll($arguments);

// this will return a stream for only attendees who have paid, are an Attendee, they have completed their registration and they were last modified after 2016-04-07 19:43:26
// also notice we didn't run 'setEvent' again, this is because until you set an event again it will use the previously set one
// nb: attempting to get a resource which depends on an id prior to setting it will throw an exception

$client->attendees
    ->setEvent(1)
    ->get(103);

$client->attendees
    ->setEvent(1)
    ->update(103, [
        'customData' => [
            [
                'key' => 'Receive Newsletter',
                'value' => 'false',
            ],
            [
                'key' => 'CRM ID',
                'value' => '123456'
            ]
        ]
    ]);

$client->attendees
    ->setEvent(1)
    ->auth('[email protected]', 'DWS7C6Z');

$client->sessions
    ->setEvent(3)
    ->getAll();

$client->sessions
    ->setEvent(3)
    ->get(17);

$client->people
    ->get(99);

$client->invoices
    ->getAll();

// or with parameter
$client->invoices
    ->getAll(1);

$client->invoices
    ->get(1);

$client->invoices
    ->update(1, [
        'externalInvoiceReference' => 'EF123456'
    ]);
// Because EventsForce have only opened one field to be updated on an invoice this method has a helper as below:
$client->invoices
    ->updateExternalRef(1, 'EF123456');

$client->payments
    ->setInvoice(2)
    ->getAll();

$client->payments
    ->setInvoice(2)
    ->setPostDefault('currencyCode', 'GBP') // you can use setPostDefault to set a default payment parameter, this allows you to set default then post multiple payments using similar details
    ->setPostDefault('comment', 'Made by My Application') // set a default comment for all future payments
    ->post(['amount' => 29.99]); // post one payment

$client->payments
    ->post(['amount' => 27.79]); // post another

$client->payments
    ->setInvoice(2)
    ->get(2);

$body = $response->getBody();

$status_code = $response->getStatusCode();