2017 © Pedro Peláez
 

library api

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

image

newsletter2go/api

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

  • Tuesday, November 28, 2017
  • by Newsletter2Go
  • Repository
  • 6 Watchers
  • 3 Stars
  • 2,361 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 13 Forks
  • 4 Open issues
  • 6 Versions
  • 22 % Grown

The README.md

#

, (*1)

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., (*2)

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, (*3)

Requirements

  • PHP 5.6 >=

Installation and Usage

Composer

To install from the cli with Composer, simply run:, (*4)

composer require newsletter2go/api
composer install

Repository

You can also download the standalone class from this repository and add it to your PHP project., (*5)

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 - Contacts - Segments - Attributes - Campaigns - Forms - Company, (*6)

# Lists - ### getListDetails() getListDetails() - API Documentation Get all information for one specific list., (*7)

Parameter Type Description
$listId @param string List ID you want to get details from.
stdClass @return stdClass returned Object.
Parameter Type Description
$name @param string List name
$uses_econda @param boolean Enable/Disable Encoda tracking.
$uses_googleanalytics @param boolean Enable/Disable Google tracking.
$has_opentracking @param boolean Enable/Disable tracking for E-mail opening.
$has_clicktracking @param boolean Enable/Disable tracking for clicks in newsletter.
$has_conversiontracking @param boolean Enable/Disable Conversion tracking.
$imprint @param string Link to company imprint.
$header_from_email @param string Default sender address for E-mails.
$header_from_name @param string Default sender name for E-mails.
$header_reply_email @param string Default address for replied E-mails.
$header_reply_name @param string Default sender name for replied E-mail.
$tracking_url @param string Additional URL tracking.
$landingpage @param string Landing page URL.
$use_ecg_list @param boolean Enable/Disable ECG.
stdClass @return stdClass returned Object.
Parameter Type Description
$listId @param string List ID to perform the actions on.
$name @param string List name.
$uses_econda @param boolean Enable/Disable Encoda tracking.
$uses_googleanalytics @param boolean Enable/Disable Google tracking.
$has_opentracking @param boolean Enable/Disable tracking for E-mail opening.
$has_clicktracking @param boolean Enable/Disable tracking for clicks in newsletter.
$has_conversiontracking @param boolean Enable/Disable Conversion tracking.
$imprint @param string Link to company imprint.
$header_from_email @param string Default sender address for E-mails.
$header_from_name @param string Default sender name for E-mails.
$header_reply_email @param string Default address for replied E-mails.
$header_reply_name @param string Default sender name for replied E-mail.
$tracking_url @param string Additional URL tracking.
$landingpage @param string Landing page URL.
$use_ecg_list @param boolean Enable/Disable ECG.
stdClass @return stdClass returned Object.

Be careful! You're irrevocably deleting the entire list with all campaigns and contacts., (*8)

Parameter Type Description
$listId @param string List ID to perform the actions on.
stdClass @return stdClass returned Object.

Contacts

Parameter Type Description
stdClass @return stdClass returned Object.
Parameter Type Description
$recipientId @param string description
stdClass @return stdClass returnedObject
Parameter Type Description
$listId @param string Recipient ID to perform the actions on.
$email @param string Recipient's e-mail.
$phone @param string Recipient's phone.
$gender @param string Recipient's gender.
$first_name @param string Recipient's name.
$last_name @param string Recipient's last name
$is_unsubscribed @param boolean Recipient's subscription status.
$is_blacklisted @param boolean Recipient's blacklist status.
stdClass @return stdClass returnedObject
Parameter Type Description
$listId @param string List ID to perform the actions on.
$recipientId @param string Recipient ID to be deleted.
stdClass @return stdClass returnedObject

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, (*9)

Parameter Type Description
$listId @param string List ID to perform the actions on.
$email @param string New e-mail address.
$phone @param string New phone address.
$gender @param string New gender.
$first_name @param string New name.
$last_name @param string New last name.
$is_unsubscribed @param boolean Redifine recipient's subscription status.
$is_blacklisted @param boolean Redifine recipient's blacklist status.
$filter @param string Query variable. Make sure to do URL encoding to the variable.
stdClass @return stdClass returnedObject
Parameter Type Description
$listId @param string List ID to perform the actions on.
$email @param string New e-mail address.
$phone @param string New phone address.
$gender @param string New gender.
$first_name @param string New name.
$last_name @param string New last name.
$is_unsubscribed @param boolean Redifine recipient's subscription status.
$is_blacklisted @param boolean Redifine recipient's blacklist status.
stdClass @return stdClass returnedObject

Segments

Parameter Type Description
$listId @param string List ID to perform the actions on.
stdClass @return stdClass returnedObject
Parameter Type Description
$listId @param string List ID to perform the actions on.
$name @param string description
stdClass @return stdClass returnedObject
  • ### 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.
Parameter Type Description
$listId @param string List ID to perform the actions on.
$name @param string Segment name
$filter @param string Conditions upon which the auto-update action is executed
stdClass @return stdClass returnedObject
Parameter Type Description
$segmentId @param string Segment ID to update.
$name @param string Name to be updated
stdClass @return stdClass returnedObject
Parameter Type Description
$segmentId @param string Segment ID to be deleted
stdClass @return stdClass returnedObject
Parameter Type Description
$listId @param string List ID to perform the actions on.
$segmentId @param string Segment ID to retrieve the recipients from.
stdClass @return stdClass returnedObject
Parameter Type Description
$listId @param string List ID to perform the actions on.
$segmentId @param string Segment ID where the recipient will be
$recipientId @param string description
stdClass @return stdClass returnedObject

If you don't pass a $filter, all your recipients will be deleted from the group irrevocably., (*10)

Parameter Type Description
$segmentId @param string Segment ID for deletion
$recipientId @param string Recipient ID to be deleted
$filter @param string Filter parameter for deletion
stdClass @return stdClass returnedObject

Attributes

Parameter Type Description
$listId @param string List ID to perform the actions on.
stdClass @return stdClass returnedObject
Parameter Type Description
$attributeId @param string Attribute ID to be retrieved.
stdClass @return stdClass returnedObject
Parameter Type Description
$listId @param string List ID to perform the actions on.
$name @param string Attribute name
$display @param string Attribute display
$type @param string Attribute type.
$sub_type @param string
$is_enum @param boolean Represented by a number.
$is_public @param boolean Visibility of the attribute.
$is_multiselect @param boolean Can hold multiple options.
$html_element_type @param string Description for HTML element.
$is_global @param boolean Define if this attribute should apply to all lists.
stdClass @return stdClass returnedObject
Parameter Type Description
$listId @param string List ID to perform the actions on.
$attributeId @param string Attribute ID to be updated.
$attributename @param string New attribute name.
$value @param string New attribute value.
stdClass @return stdClass returnedObject
Parameter Type Description
$listId @param string List ID to perform the actions on.
$attributeId @param string Attribute ID to be deleted.
stdClass @return stdClass returnedObject

Campaigns

Parameter Type Description
$listId @param string List ID to perform the actions on.
stdClass @return stdClass returnedObject
Parameter Type Description
$newsletterId @param string Newsletter ID to be sent.
stdClass @return stdClass returnedObject
Parameter Type Description
$newsletterId @param string Newsletter ID to be retrieved.
stdClass @return stdClass returnedObject
  • ### 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.
Parameter Type Description
$listId @param string List ID to perform the actions on.
$type @param string Mailing type "default", "doi", "transactional"
$name @param string Name for new mailing
$has_open_tracking @param boolean Enabled/Disabled open tracking.
$has_click_tracking @param boolean Enabled/Disabled click tracking.
$has_conversion_tracking @param boolean Enabled/Disabled conversion tracking.
stdClass @return stdClass returnedObject
  • ### 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].
Parameter Type Description
$newsletterId @param string Newsletter ID to be tested.
$address @param string E-mail address where the test should arrive.
stdClass @return stdClass returnedObject
  • sendOneTimeMailing()

    sendOneTimeMailing() - API Documentation There are different ways to address a mailing., (*11)

  • To the whole contac list by using the list_id., (*12)

  • 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., (*13)

Parameter Type Description
$newsletterId @param string Newsletter ID to be sent.
$time @param string Time for execution. Please format it to ISO-8601
$groupIds @param string Groups (Segments) to be addressed.
$recipientIds @param string Individual recipient e-mails.
$listId @param string List ID where to be addressed.
$state @param boolean Active/Unactive campaign.
stdClass @return stdClass returnedObject
  • ### 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.
Parameter Type Description
$newsletterId @param string Newsletter ID to be sent.
$time @param string Time for execution. Please format it to ISO-8601
$address @param string Individual recipient e-mail.
stdClass @return stdClass returnedObject
  • ### 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.
Parameter Type Description
$newsletterId @param Newsletter ID to be modified.
$name @param Updated mailing name.
$isDeleted @param Enabled/Disabled deletion state.
$has_open_tracking @param Enabled/Disabled email open tracking.
$has_click_tracking @param boolean Enabled/Disabled click tracking.
$has_conversion_tracking @param boolean Enabled/Disabled conversion tracking.
stdClass @return stdClass returnedObject
Parameter Type Description
$newsletterId @param string Newsletter ID to retrieve reports.
$filter @param string FIQL advanced filter.
stdClass @return stdClass returnedObject

Forms

Parameter Type Description
$formId @param string description
stdClass @return stdClass returnedObject
Parameter Type Description
$formId @param string Form Id to be submitted.
$address @param string E-mail address of form recipient.
stdClass @return stdClass returnedObject

Company

Parameter Type Description
stdClass @return stdClass returnedObject

The Versions

28/11 2017

dev-master

9999999-dev

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

  Sources   Download

GPL-3.0

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Newsletter2Go GmbH

api rest client newsletter2go

26/04 2017

1.1.1

1.1.1.0

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

  Sources   Download

GPL-3.0

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Newsletter2Go GmbH

api rest client newsletter2go

26/04 2017

1.1.0

1.1.0.0

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

  Sources   Download

GPL-3.0

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Newsletter2Go GmbH

api rest client newsletter2go

19/08 2016

1.0.3

1.0.3.0

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

  Sources   Download

GPL-3.0

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Newsletter2Go GmbH

api rest client newsletter2go

19/08 2016

1.0.2

1.0.2.0

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

  Sources   Download

GPL-3.0

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Newsletter2Go GmbH

api rest client newsletter2go

18/08 2016

1.0.0

1.0.0.0

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

  Sources   Download

GPL-3.0

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Newsletter2Go GmbH

api rest client newsletter2go