PHP API wrapper for the Events Force API
, (*1)
An API client package for the Events Force API.
For reference to what kind of data you can pass to the API methods refer to the general API documentation.
To get a client slug / client account string see here, (*2)
Contents
- Requirements
- Installation
- Initializing
-
Full usage
- Responses
- Contributing
- Licence
composer require jbarnard/efapiphp
Note: The follow examples all use the apiexample credentials as shown here, (*3)
// Define a new client, passing in the client slug and api key
$client = new \EventsForce\Client('apiexample', '035E0A65508A4D8FAB63A983F36ACCAC');
Now you are ready to use specific resources and methods
The resources are split as shown on the api docs
E.g to access events get all you would do the following:, (*4)
$stream = $client->events->getAll();
The response is a \Psr\Http\Message\StreamInterface, (*5)
#### Events - http://docs.eventsforce.apiary.io/#reference/events
$client->events->getAll();
$client->events->get(2); // where 2 is the event id
#### Attendees - http://docs.eventsforce.apiary.io/#reference/attendees
Available parameters:
* lastModifiedAfter
* paymentStatus
* category
* registrationStatus, (*6)
$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);
Needs testing with a full access api, not just the example, (*7)
$client->attendees
->setEvent(1)
->update(103, [
'customData' => [
[
'key' => 'Receive Newsletter',
'value' => 'false',
],
[
'key' => 'CRM ID',
'value' => '123456'
]
]
]);
The value required for userID depends on the attendeeIDMode set for the event., (*8)
$client->attendees
->setEvent(1)
->auth('aliquet@mauris.co.uk', 'DWS7C6Z');
#### Sessions - http://docs.eventsforce.apiary.io/#reference/sessions
$client->sessions
->setEvent(3)
->getAll();
$client->sessions
->setEvent(3)
->get(17);
#### People - http://docs.eventsforce.apiary.io/#reference/people
$client->people
->get(99);
#### Invoices - http://docs.eventsforce.apiary.io/#reference/invoices
Can have an optional invoiceNumberAfter parameter which will return the items with id's from that point, defaults to 0, (*9)
$client->invoices
->getAll();
// or with parameter
$client->invoices
->getAll(1);
$client->invoices
->get(1);
Needs testing with a full access api, not just the example, (*10)
$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');
#### Payments - http://docs.eventsforce.apiary.io/#reference/payments
$client->payments
->setInvoice(2)
->getAll();
Needs testing with a full access api, not just the example, (*11)
$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);
The methods return a response object - http://guzzle3.readthedocs.org/http-client/response.html
You can get the body of the response by calling:, (*12)
$body = $response->getBody();
You can also get the status code:, (*13)
$status_code = $response->getStatusCode();
There are other helpers that can be seen here: http://guzzle3.readthedocs.org/http-client/response.html, (*14)
Example JSON output:
JSON
{
"responseCode": 200,
"systemErrorCode": "",
"systemErrorMessage": "",
"userErrorMessage": "",
"itemCount": 2,
"data": [
{
"detailsURL": "https://www.eventsforce.net/apiexample/api/v2/events/1.json",
"eventID": 1,
"eventName": "Test API event",
"eventStatus": "notlive",
"eventStartDateTime": "2014-01-23T09:00:00Z",
"eventEndDateTime": "2014-01-23T17:00:00Z",
"venueName": ""
},
{
"detailsURL": "https://www.eventsforce.net/apiexample/api/v2/events/2.json",
"eventID": 2,
"eventName": "Test API event with payment",
"eventStatus": "notlive",
"eventStartDateTime": "2014-01-23T09:00:00Z",
"eventEndDateTime": "2014-01-23T17:00:00Z",
"venueName": ""
}
]
}
, (*15)
Found in CONTRIBUTING.md, (*16)
Found in LICENSE file, (*17)