Home / Subscriber / store

Subscriber ‐ store


Description:

Save a subscriber

The following errors can occur:
- Token not present in request.
- Token not in the required format.
- Session does not exist.
- Session has expired.
- The user does not exist.
- No database specified.
- Database parameter not in correct format.
- You are not allowed to access this database.
- The email parameter is required.
- The email parameter is invalid.
- The selected subscriber does not exist.
- An id/list of ids are required.
- The subscriber parameter is required.
- The source parameter should be an unsigned integer.
- The source parameter does not contain a valid source.
- The mailing parameter contains an invalid value type.
- The selected mailing does not exist.
- One or more selections are the same or not integers.
- One or more selections do not exist.
- The selections parameter must contain an array or the stringular value `empty`.
- One or more categories are the same or not integers.
- One or more categories do not exist.
- The categories parameter contains an invalid value type.
- One or more languages are the same or not integers.
- The languages parameter contains an invalid value type.
- The parameter perfomed should be subscriber or listowner (defaults to subscriber).
- The options parameter should be an object.
- The options parameter contains a key %s, which is not allowed.
- The options[subscriber] parameter should be update or create (defaults to create).
- The options[language] parameter should be only or add (defaults to add).
- The options[selection] parameter should be add, removeOther or ignore (defaults to removeOther).
- The options[selection] parameter should be add, removeOther or ignore (defaults to removeOther).
- The options[selection] parameter should be yes or no (defaults to no).
- The options[optin] parameter should be none, confirmed or double (defaults to none).
- The options[optin_mail_id] parameter should be a positive integer.
- Selection mail options[optin_mail_id] does not exist.
- The options[resend_optin] parameter should be yes or no (defaults to no).
- Cannot continue, pretend is set.
- Failed to save the subscriber.
- You cannot use optin_id and optin_text at the same time.
- The optin parameter should be an unsigned integer.
- Something went wrong. Please try again later.

Example:

You should call this function as followed:
- rest/v2/subscriber/store?token=TOKEN&database=DATABASE_ID&email=STRING&source=SOURCE_ID&optin_id=OPTIN_ID
&options[subscriber]=update&options[language]=add&options[category]=add&options[overwrite_source]=no
&options[selection]=add&options[resend_optin]=yes&options[optin]=double&options[optin_mail_id]=MAILING_ID
&pretend=0&subscriber[firstname]=FIRSTNAME&subscriber[lastname]=LASTNAME&languages[0]=LANGUAGE_ID
&selections[0]=SELECTION_ID&mailing[0]=1&categories[0]=CATEGORY_ID&categories[1]=CATEGORY_ID&performed=subscriber

                require_once 'Rest.php';

                $username = 'my_username';
                $password = 'my_password';
                $database = '999';

                $rest = new Rest($username, $password, $database);
                $result = $rest->call('subscriber/store', [
                	'email' => 'STRING',
'source' => 'SOURCE_ID',
'optin_id' => 'OPTIN_ID',
'options' => [
'subscriber' => 'update',
'language' => 'add',
'category' => 'add',
'overwrite_source' => 'no',
'selection' => 'add',
'resend_optin' => 'yes',
'optin' => 'double',
'optin_mail_id' => 'MAILING_ID'
],
'pretend' => '0',
'subscriber' => [
'firstname' => 'FIRSTNAME',
'lastname' => 'LASTNAME'
],
'languages => ['LANGUAGE_ID']
'selections => ['SELECTION_ID']
'mailing => ['1']
'categories' => [
'CATEGORY_ID',
'CATEGORY_ID'
],
'performed' => 'subscriber' ], 'GET'); var_dump($result);

Parameters:

The following parameters this method can/should be called with:

key: email
values: string, valid e-mail address, required
what: E-mail address of the subscriber

key: source
values: integer, the ID of the source, required
what: The source of the subscriber

key: optin_id
values: integer, the ID of the optin
what: The optin_id of the subscriber (you can only use or optin_id or optin_text)

key: optin_text
values: string, the text of the optin
what: The text of the optin for the subscriber (you can only use or optin_id or optin_text)

key: options
values: array, not required
what: Set subscriber options
Can Contain: subscriber,language,selection,category,overwrite_source,optin,optin_mail_id,resend_optin

parent: options
key: subscriber
values: string (update' or 'create'), not required
what: Create or update the subscriber

parent: options
key: language
values: string ('only' or 'add'), not required
what: Add the language to the existing language of the subscriber, or overwrite it

parent: options
key: selection
values: string ('add' or 'removeOther' or 'ignore'), not required
what: Add the selection to the existing selections, or overwrite the existing selections, or ignore the new selection

parent: options
key: category
values: string ('add' or 'removeOther' or 'ignore'), not required
what: Add the category to the existing categories of a subscriber, or overwrite the existing
categories of a subscriber, or ignore the new category/categories

parent: options
key: overwrite_source
values: string ('yes' or 'no'), not required
what: Overwrite te current source of the subscriber

parent: options
key: optin
values: string ('none' or 'confirmed' or 'double'), not required
what: Send a confirmation mail to the subscriber.

parent: options
key: optin_mail_id
values: integer, id of a existing mailing in the database, only required when the optin is set
what: Set a mailing id for the confirmation mail for the subscriber

parent: options
key: resend_optin
values: string ('yes' or 'no'), not required
what: Resend the option confirmation mail to the subscriber

key: pretend
values: string, (1, true, 'yes', 'on'), not required
what: Used for testing the subscriber/store. Runs the code but does not save it to the database.

key: subscriber
values: array[string] = string, Array of labels + values of the subscriber, not required
what: Set the labels (example: name, firstname, birthdate etc) of a subscriber. Labels can be different for each database.

key: languages
values: array[integer], Array of language ID's of the current database, required
what: Set language(s) of a subscriber, can be different for each database

key: selections
values: array[integer] or string 'empty', array of selection ID's, not required
what: Save the subscriber in one or more selections

key: mailing
values: integer or array[integer],ID of a existing mailing of the current database, not required
what:

key: categories
values: array[integer] or string 'empty', array of ID's of the existing categories in a database, not required
what: Set a category/categories for a subscriber

key: performed
values: string ( 'subscriber' or 'listowner'), standard on 'subscriber', not required
what: By who is the store subscriber done?

See:

The following items:
- user/login For the TOKEN.
- user/database For the DATABASE_ID
- source/findByName For the SOURCE_ID
- E-Mark Mail -> Mailing For the MAILING_ID
- language/all For the LANGUAGE_ID
- selections/findByName For the SELECTION_ID
- category/findByName For the CATEGORY_ID