1. Go to this page and download the library: Download richardhj/newsletter2go-api 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/ */
richardhj / newsletter2go-api example snippets
$users = Richardhj\Newsletter2Go\Api\Model\NewsletterUser::findAll(null, $apiCredentials);
// Use a PHPDoc comment and profit from auto suggestion
/** @var NewsletterUser $user */
foreach ($users as $user) {
// What's about naming all users "Doe"?
$user->setLastName('Doe');
// Save the user (via the API of course)
$user->save();
// $data contains all data fetched for this item
$data = $user->getData();
}
$recipient = new Richardhj\Newsletter2Go\Api\Model\NewsletterRecipient();
$recipient->setApiCredentials($apiCredentials);
$recipient
->setListId('abc123')
->setFirstName('John')
->setLastName('Doe')
->setEmail('[email protected]')
->setGender('m');
// Good to have an id, otherwise the email address will be the primary key and you will not be able to change the email address of a recipient properly
$recipient->setId('xyz123');
// Update an existing recipient (when id given or email address known in Newsletter2Go) or create a new recipient
$recipient->save();