Documentation Index
Fetch the complete documentation index at: https://docs.mailglyph.com/llms.txt
Use this file to discover all available pages before exploring further.
Use a secret key client for contacts methods.
<?php
use MailGlyph\MailGlyph;
$client = new MailGlyph($_ENV['MAILGLYPH_SECRET_KEY']);
Use cursor pagination for large lists:
<?php
$page1 = $client->contacts->list([
'limit' => 50,
'subscribed' => true,
'search' => 'john',
]);
echo count($page1['data']) . PHP_EOL;
var_dump($page1['hasMore']);
echo $page1['cursor'] . PHP_EOL;
Fetch the next page with cursor:
<?php
if ($page1['hasMore'] && $page1['cursor'] !== null) {
$page2 = $client->contacts->list([
'limit' => 50,
'cursor' => $page1['cursor'],
]);
echo count($page2['data']) . PHP_EOL;
}
<?php
$created = $client->contacts->create([
'email' => '[email protected]',
'subscribed' => true,
'data' => [
'firstName' => 'John',
'plan' => 'premium',
],
]);
echo $created->id . PHP_EOL;
var_dump($created->meta['isNew'] ?? null);
var_dump($created->meta['isUpdate'] ?? null);
<?php
$contact = $client->contacts->get($created->id);
echo $contact->email . PHP_EOL;
var_dump($contact->subscribed);
<?php
$updated = $client->contacts->update($created->id, [
'subscribed' => false,
'data' => [
'plan' => 'pro',
],
]);
var_dump($updated->subscribed);
echo $updated->data['plan'] . PHP_EOL;
<?php
$subscribedCount = $client->contacts->count(['subscribed' => true]);
echo $subscribedCount . PHP_EOL;
<?php
$client->contacts->delete($created->id);
See full details in the Contacts API reference.