PHP code example of picr / php-autopilothq
1. Go to this page and download the library: Download picr/php-autopilothq 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/ */
picr / php-autopilothq example snippets
$manager = new AutopilotManager($apiKey);
$manager->getContact($id|$email);
$manager->saveContact(AutopilotContact $contact);
$manager->saveContacts(array $contacts);
$manager->deleteContact($id|$email);
$manager->unsubscribeContact($id|$email);
$manager->subscribeContact($id|$email);
$manager->updateContactEmail($oldEmail, $newEmail);
$manager->getAllLists();
$manager->createList($list);
$manager->getListByName($list);
//TODO: AutopilotHQ hasn't implemented this yet
$manager->deleteList($list);
$manager->getAllContactsInList($list);
$manager->addContactToList($list, $id|$email);
$manager->removeContactFromList($list, $id|$email);
$manager->checkContactInList($list, $id|$email);
$manager->allTriggers();
$manager->addContactToJourney($journey, $id|$email);
$manager->allRestHooks();
$manager->deleteAllRestHooks();
$manager->addRestHook($event, $targetUrl);
$manager->deleteRestHook($hookId);
// magic method
$value = $contact->$name;
// getter
$value = $contact->getFieldValue($name);
// magic method
$contact->$name = $value;
// setter
$contact->setFieldValue($name, $value);
// magic method
unset($contact->$name);
// method
$contact->unsetFieldValue($name);
// magic method
isset($contact->$name);
// method
$contact->issetFieldValue($name);
//NOTE: this only reads cached "lists" array returned for a "contact info" request
$contact->getAllContactLists();
//NOTE: this only reads cached "lists" array returned for a "contact info" request
$contact->hasList($list);
// read array of values and populate properties
// NOTE: automatically formats attributes according to AutopilotHQ's "naming convention" (doesn't really exist)
$contact->fill([
'firstName' => 'John',
'lastName' => 'Smith',
'age' => 42,
]);
// return array ready to be pushed to the API
$user = $contact->toRequest();
// return array of [ property => value ] no matter if custom or defined field
$user = $contact->toArray();
/* [
* 'firstName' => 'John',
* 'lastName' => 'Smith',
* 'age' => 42,
* ]
*/
// json representation of "toArray()"
$user = $contact->jsonSerialze();
$user = json_encode($contact);