<?php // include the Eloqua REST client and models include_once '../eloquaRequest.php'; include_once '../models/data/contact.php'; // instantiate a new instance of the Client $client = new EloquaRequest('site', 'user', 'password', 'https://secure.eloqua.com/API/REST/1.0'); // invoke a GET request to List all contacts $contacts = $client->get('/data/contacts?search=*&count=100&page=1'); // instantiate a new instance of the Contact class $contact = new Contact(); $contact->firstName = 'Sample'; $contact->lastName = 'Last'; $contact->emailAddress = '*****@*****.**'; // invoke a POST request to create the contact $response = $client->post('/data/contact', $contact); // retrieve the ID of the new contact $contactId = $response->id; // change the contact's first name $contact->id = $contactId; $contact->firstName = 'updated'; // invoke a PUT request to update the contact $response = $client->put('/data/contact/' . $contactId, $contact); // delete the contact $client->delete('/data/contact/' . $contactId);
<?php // include the request library and models include '../eloquaRequest.php'; include '../models/data/formData.php'; // instantiate a new instance of the request class $request = new EloquaRequest('site', 'user', 'password', 'baseUrl'); // populate values for each field, note that you can describe // a form and its fields using the following endpoint : GET /assets/form/{id} // assumes a form field (Name) with id : 1001 $nameField = new FieldValue(); $nameField->id = 1001; $nameField->value = 'Fred'; $nameField->type = 'FieldValue'; // assumes a form field (Email) with id : 1002 $emailField = new FieldValue(); $emailField->id = 1002; $emailField->value = '*****@*****.**'; $emailField->type = 'FieldValue'; // add the fieldValues to a collection $fieldValues = array($nameField, $emailField); // populate the form data submission request $submitData = new formData(); $submitData->submittedByContactId = 1001; $submitData->fieldValues = $fieldValues; $submitData->type = 'FormData'; // invoke an HTTP Post request to submit the form data $response = $request->post('/data/form/1011', $submitData);