Módulo member

1.List contacts

Service:

/member/list

List all contacts from all list filtering by e-mail

Parameters:

ParameterMailListsIds
MandatoryNO
TypeArray
ExplanationGet only users from selected lists
ExampleMailListsIds[]=125
Parametercount
MandatoryNO
TypeInteger number
ExplanationMaximum number of users to be returned
Examplecount=10
Parameterabsolutepage
MandatoryNO
TypeInteger number
ExplanationRecord page "count" to be accessed .If count is equal to 10 and absolutepage is equal to 3, then, we will start viewing from contact number 31.
Exampleabsolutepage=3
Parameterfilter
MandatoryNO
TypeCharacter chain
ExplanationE-mail or part of the e-mail by which contacts are filtered
Examplefilter=nombre@dominio.com
ParameterorderBy
MandatoryNO
TypeNúmero entero Cadena de caracteres
Valores posibles:
name
id
ExplanationField by which the list will be ordered.
ExampleorderBy=name
Parameterdesc
MandatoryNO
TypeNúmero entero
Valores posibles:
0
1
ExplanationField by which the list will be ordered.
Exampledesc=1

Errors:

errorMsg_formValidations
One or more of the entry parameters are incorrect, missing or mandatory. A structure of type "Parámetro inválido"=>"error" is associated.
errorMsg_membersNotFound
Contacts could not be retrieved

Exit structure:

list.item.MemberID
Contact ID
list.item.Email
Contact e-mail
list.item.BounceType
Type of bounce [1=hard bounce|2=Soft Bounce|3=No Bounces]
list.item.MailLists.activeCount
Number of lists to which user is associated
list.item.MailLists.item.MailListID
Contact list ID
list.item.MailLists.item.SubscriptionStatus
User subscription status on the list
list.item.MailLists.item.MailListName
List name
list.item.CustomFields.item.CustomField<1..100>
Custom fields of member
list.pager.absolutepage
Page being displayed
list.pager.pagecount
Total number of pages
list.pager.totalCount
Total number of records
list.pager.rowCount
Number of records per page.
customfields
List of custom fields created by the administrator
customfields.rows.CustomFieldID
Custom field IDs
customfields.rows.Title
Custom field titles
criteria.filter
Filter entered as parameter

** Only relevant fields are explained or listed

2.Create or modify contact information

Service:

/member/edit

It retrieves, creates or modifies contact information.

This service behaves in different ways depending on how we make the call. If we do it via GET and pass the MemberID parameter, it will try to retrieve the contact information. If we use POST, it will try to modify or create the contact depending on whether the MemberID parameter is defined or not.

Parameters:

ParameterMemberID
MandatoryNO
TypeInteger number
ExplanationContact ID to be modified. Only necessary if you want to retrieve the information or modify the contact.
ExampleMemberID=2
ParameterMailListID
MandatoryNO
TypeInteger number
ExplanationList to which contact will be initially subscribed to. Only one list must be assigned
ExampleMailListID=4
ParameterEmail
MandatoryNO
TypeCharacter chain
ExplanationE-mail address to be subscribed
ExampleEmail=rogelio@donweb.com
ParameterCustomField<1..100>
MandatoryNO
TypeArreglo de cadena
ExplanationValues for each Custom field- The numeric part of the parameter is the custom field ID "CustomFieldID"
ExampleCustomField1=rogelio&CustomField3=hombre&CustomField5=argentina

Errors:

errorMsg_formValidations
One or more of the parameters entered are incorrect, missing or mandatory
errorMsg_memberNotFound
User to be modified was not found. It can only appear during a modification
errorMsg_memberNotSaved
Due to an unexpected error, contact could not be saved.
errorMsg_memberBanned
Contact could not be subscribed to list since the e-mail is forbidden

Exit structure:

member.MemberID
Contact ID
member.Email
Contact e-mail
member.CustomFields
member.CustomFields.item.CustomField<1..100>

Custom fields of member

** Only relevant fields are explained and listed.

3.Change contact status (Subscribe, unsubscribe, Disassociate, etc)

Service:

/member/changestaus

It modifies the status of one or more contacts associated to one or more lists.

Parameters:

ParameterMemberIds
MandatoryYES
TypeArray for integer numbers
ExplanationAll contact IDs to be modified
ExampleMemberIds[]=1&MemberIds[]=2
ParameterMailListsIds
MandatoryYES
TypeArray for integer numbers
ExplanationAll contact lists to be used to operate
ExampleMailListsIds[]=4&MailListsIds[]=9
ParameterSubscriptionStatus
MandatoryYES
TypeCharacter chain
ExplanationIndica el estado que se quiere asignar a los contactos.
Valores posibles:PendingOptIn (pendiente de confirmación)
Subscribed (suscripto)
Unsubscribed (desuscripto)
Deleted (remover de la lista)
ExampleSubscriptionStatus=Subscribed

Errors:

errorMsg_formValidations
One or several of the parameters entered are incorrect, missing or required.
invalidMaillist
ID lists of invalid contact lists. Do not exist
invalidMember
ID lists of invalid contacts. Do not exist
subscribed
ID list of contacts subscribed successfully. This parameter is only present if there was an error and "notSubscribed" is present.
notSubscribed
ID list of valid contacts non-subscribed
countNotSubscribed
Number of non-subscribed contacts (notSubscribed invalidMember)

Exit structure:

countChanged=number
Number of contacts that were modified successfully
changestatus
changestatus.detail
changestatus.detail.changed
array that has a key for each MemberID whose value is an array of each MaillistID for which the status has been modified

Example:

changestatus: {
            detail: {
            changed: {
                2:["4","9"],
                1:["4","9"]
                     }
                    }
                SubscriptionStatus: "Subscribed"
                  }
            countChanged: 2

4.Unsubscribe contacts per e-mail

Service:

/member/unsubscribebyemail

It removes one or more contacts from one or several lists filtering by e-mail

Parameters:

Parameteremails
MandatoryYES
TypeArray of chains
ExplanationAll contact e-mail addresses to be unsubscribed.
Exampleemails[]=toto@tritolo.com&emails[]=juena@gmail.com
ParameterMailListsIds
MandatoryYES
TypeArray for integer numbers
ExplanationAll contact lists to which MembersIds are to be unsubscribed.
ExampleMailListsIds[]=4&MailListsIds[]=9
Parameterban
MandatoryNO
TypeInteger[0|1]
ExplanationCreate an exclusion rule per e-mail of the e-mail parameter
Exampleban=1

Errors:

errorMsg_formValidations
One or several of the parameters entered are incorrect, missing or required.

Exit structure:

countUnsubscribed
Number of users successfully subscribed
notUnsubscribed
Array of e-mails of valid contacts Non unsubscribed
countNotUnsubscribed
Number of contacts non unsubscribed (notUnsubscribed invalidMember)

5.Useful implementation examples in PHP:

In this example, we will :

Create contact with e-mail=juanperez@gmail.com, Name=Juan, last name=Perez and SUBSCRIBE to list with ID=1 .

Subscribe contact to list with ID=2.

Unsubscribe from list 1 the contact created in step 1

Look for contact created in step 1 within list 2

Script

TEAXTAREA with the code of the script member.php

Script PHP Exit

Nuevo Contacto: 19962 - juanperez@gmail.com: Juan Perez

User successfully subscribed to list 2

User successfully unsubscribed from list 1

El usuario 19962 - juanperez@gmail.com (Juan Perez) esta suscripto a la lista 2


<?php$baseURL = 'https://app.envialosimple.com';$apiKey = 'KEY';//Create a new contact in the list 1$params = array();$params['APIKey']=$apiKey;$params['MailListID']=1;$params['Email']='juanperez@gmail.com';$params['CustomField1']='Juan';$params['CustomField2']='Perez';$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $baseURL.'/member/edit/format/json');curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));$jsonResponse = curl_exec($ch);curl_close($ch);$response = json_decode($jsonResponse, true);$id = $response['root']['ajaxResponse']['member']['MemberID'];$email = $response['root']['ajaxResponse']['member']['Email'];$nombre = $response['root']['ajaxResponse']['member']['CustomFields']['item']['CustomField1']['Values']['Option'][0]['Value'];$apellido = $response['root']['ajaxResponse']['member']['CustomFields']['item']['CustomField2']['Values']['Option'][0]['Value'];echo "Nuevo Contacto: $id - $email: $nombre $apellido \n";//Subscribe contact to list with ID=2$params = array();$params['APIKey']=$apiKey;$params['MailListsIds']=array(2);$params['MemberIds']=array($id);$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $baseURL.'/member/changestatus/SubscriptionStatus/Subscribed/format/json');curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));$jsonResponse = curl_exec($ch);curl_close($ch);$response = json_decode($jsonResponse, true);$exito = $response['root']['ajaxResponse']['success'];$count = $response['root']['ajaxResponse']['countSubscribed'];if($exito && $count=1){echo "Contacto suscripto correctamente a la lista 2\n";}else{echo "No se pudo suscribir correctamente a la lista 2\n";print_r($response);exit;}//Unsubscribe contact from list 1$params = array();$params['APIKey']=$apiKey;$params['MailListsIds']=array(1);$params['MemberIds']=array($id);$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $baseURL.'/member/changestatus/SubscriptionStatus/Unsubscribed/format/json');curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));$jsonResponse = curl_exec($ch);curl_close($ch);$response = json_decode($jsonResponse, true);$exito = $response['root']['ajaxResponse']['success'];$count = $response['root']['ajaxResponse']['countUnsubscribed'];if($exito && $count=1){echo "User successfully unsubscribed from list 1\n";}else{echo "No se pudo desuscribir correctamente de la lista 1\n";print_r($response);exit;}//Look for contact created in step 1 within list 2$params = array();$params['APIKey']=$apiKey;$params['MailListID']=2;$params['filter']='juanperez';$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $baseURL.'/member/listbymaillist/format/json?'.http_build_query($params));curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);$jsonResponse = curl_exec($ch);curl_close($ch);$response = json_decode($jsonResponse, true);foreach ($response['root']['ajaxResponse']['list']['item'] as $item){$tmpid = $item['MemberID'];$tmpemail = $item['Email'];$tmpnombre = $item['CustomFields']['item']['CustomField1']['Values']['Option'][0]['Value'];$tmpapellido = $item['CustomFields']['item']['CustomField2']['Values']['Option'][0]['Value'];echo "El Contacto $tmpid - $tmpemail ($tmpnombre $tmpapellido) esta suscripto a la lista 2\n";}?>