newsletter2go / api
PHP API implementation of the Newsletter2Go REST API (https://docs.newsletter2go.com/)
Installs: 49 684
Dependents: 1
Suggesters: 0
Security: 0
Stars: 9
Watchers: 6
Forks: 21
Open Issues: 6
Requires
- php: >=5.3.0
- ext-curl: *
README
newsletter2go-api-php
This PHP library is intended to be used as a facade to our API exposed services. Through this implementation, you can perform the most common operations included in our official API documentation site.
Additional Information:
- API version: 1.4
- This library follows the structure from our Postman Collection File
- You can post any request, bug or issue or also reach us at: implementation@newsletter2go.com
Requirements
- PHP 5.6 >=
Installation and Usage
Composer
To install from the cli with Composer, simply run:
composer require newsletter2go/api
composer install
Repository
You can also download the standalone class from this repository and add it to your PHP project.
Implementation
- This example shows how to setup your account credentials and make further API calls.
<?php
namespace NL2GO;
//Import the standalone class in your working directory
require_once '/Newsletter2Go_REST_Api.php';
//Add your account credentials
$authKey = "your auth key here";
$userEmail = "login email address";
$userPassword = "login password";
//Instantiate the Newsletter2Go_REST_Api
$api = new Newsletter2Go_REST_Api($authKey, $userEmail, $userPassword);
//Allow SSL check
$api->setSSLVerification(true);
//Retrieve and display all the contact lists stored your account
$lists = $api->getLists();
var_dump($lists);
The following are the supported Entities in this library:
Lists
getListDetails() - API Documentation Get all information for one specific list.
createList() - API Documentation Create a new list.
updateList() - API Documentation
deleteList() - API Documentation Delete a specific list by its ID
Be careful! You're irrevocably deleting the entire list with all campaigns and contacts.
Contacts
getRecipients() - API Documentation Get recipients from any list.
getRecipient() - API Documentation Get the details of one recipient.
updateRecipientList() - API Documentation Create one or more recipients. If the email address already exists, the existing recipient will get updated.
deleteRecipientsFromList() - API Documentation Get recipients from a specific list.
updateRecipients() - API Documentation Update multiple / all recipients in one list.
Make sure to pass the
$filter
variable or all your recipients in the list will be updated. E.g: /{{list_id}}/recipients?_filter=email%3DLIKE%3D%22%example%25%22
updateRecipient() - API Documentation
_Update one recipient only by passing its $recipientId
.
Segments
getSegmentsList() - API Documentation
createSegment() - API Documentation
createDynamicSegment() - API Documentation
The attribute $filter
should be the conditions upon which the auto-update action is executed.
The attribute $is_dynamic
defines wether the segment will auto-update or not.
updateSegment() - API Documentation
deleteSegment() - API Documentation
getRecipientSegment() - API Documentation Gets all recipients from specified segment.
addRecipientSegment() - API Documentation Add one recipient to the segment.
deleteRecipientsSegment() - API Documentation Delete recipient from one or multiple recipients from segment.
If you don't pass a
$filter
, all your recipients will be deleted from the group irrevocably.
Attributes
getAttributesList() - API Documentation Retrieve attributes from a list.
getAttributeDetails() - API Documentation Get metadata from the attribute.
createAttributeList() - API Documentation Create a new custom attribute on a given list.
updateAttribute() - API Documentation
deleteAttribute() - API Documentation
Campaigns
getMailingsList() - API Documentation
getMailing() - API Documentation
getMailingVersions() - API Documentation
createMailing() - API Documentation
If your list has default values for header_from_email
, header_from_name
, header_reply_email
and/or header_reply_name
, those will be used in case you don't pass them in this call.
sendTest() - API Documentation
This will send a test but leave the mailing status untouched.
Be aware that the subject line will be prepended by [TEST]
.
sendOneTimeMailing() - API Documentation There are different ways to address a mailing.
- To the whole contac list by using the
list_id
. - To single segments (using the
group_ids
field). - To single recipients only (by using the
recipient_ids
together with thelist_selected
field set to false) and - A combination of the above.
Important: Please take into account, that you have to set the list_selected
field to false, if you like to send to single recipients only or together with segments. This makes clear that the newsletter will not be sent to the whole contact list.
sendTransactional() - API Documentation
You can pass other data fields (such as first_name
or custom attributes) in the recipient
object as well and reference them in the body of the email.
updateMailing() - API Documentation
If you want to be able to trigger automated mailings, make sure that the state is set to active
. Use list_selected: true
to send to the whole list, pass an array of group ids in the group_ids
or send to individual contacts by passing an array in the recipient_ids
parameter.
getSpecificMailingReports() - API Documentation This call is useful for automated mailings that run every day since it returns the reports by day.
Forms
submitForm() - API Documentation
Company
getCompany() - API Documentation Get your company details.