PHP API implementation of the Newsletter2Go REST API (https://docs.newsletter2go.com/)

1.2.0 2019-06-24 07:13 UTC

This package is auto-updated.

Last update: 2024-10-28 18:55:36 UTC


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:

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()

getListDetails() - API Documentation Get all information for one specific list.

  • createList()

createList() - API Documentation Create a new list.

  • updateList()

updateList() - API Documentation

  • deleteList()

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()

getRecipients() - API Documentation Get recipients from any list.

  • getRecipient()

getRecipient() - API Documentation Get the details of one recipient.

  • updateRecipientList()

updateRecipientList() - API Documentation Create one or more recipients. If the email address already exists, the existing recipient will get updated.

  • deleteRecipientsFromList()

deleteRecipientsFromList() - API Documentation Get recipients from a specific list.

  • updateRecipients()

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()

updateRecipient() - API Documentation _Update one recipient only by passing its $recipientId.

Segments

  • getSegmentsList()

getSegmentsList() - API Documentation

  • createSegment()

createSegment() - API Documentation

  • createDynamicSegment()

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()

updateSegment() - API Documentation

  • deleteSegment()

deleteSegment() - API Documentation

  • getRecipientSegment()

getRecipientSegment() - API Documentation Gets all recipients from specified segment.

  • addRecipientSegment()

addRecipientSegment() - API Documentation Add one recipient to the segment.

  • deleteRecipientsSegment()

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()

getAttributesList() - API Documentation Retrieve attributes from a list.

  • getAttributeDetails()

getAttributeDetails() - API Documentation Get metadata from the attribute.

  • createAttributeList()

createAttributeList() - API Documentation Create a new custom attribute on a given list.

  • updateAttribute()

updateAttribute() - API Documentation

  • deleteAttribute()

deleteAttribute() - API Documentation

Campaigns

  • getMailingsList()

getMailingsList() - API Documentation

  • getMailing()

getMailing() - API Documentation

  • getMailingVersions()

getMailingVersions() - API Documentation

  • createMailing()

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()

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()

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 the list_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()

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()

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()

getSpecificMailingReports() - API Documentation This call is useful for automated mailings that run every day since it returns the reports by day.

Forms

  • getForm()

getForm() - API Documentation

  • submitForm()

submitForm() - API Documentation

Company

  • getCompany()

getCompany() - API Documentation Get your company details.