Snippet

The snippet service is for creating and alteration of snippets.


Deprecated

To navigate the tree structure use tree.fetchNode

fetchAll

array snippet.fetchAll( void )

Requests a list of snippets. This method has no parameters to specify as it will request all snippets regardless of the position within the folder hierarchy.

Return Values

Returns an array of associative arrays. For the possible returned elements see #find



find

array snippet.find( int snippetId )

Requests the list details of the single list id requested.

Parameters

snippetId

ID of the snippet you're requesting.

Return Values

Returns an associative array. The possible returned elements are as follows:

Name

Type

Description

snippet_id

int

Snippet Id

folder_id

int

Folder Id

name

string

Name of the snippet

update_ts

timestamp

Date and time the snippet was last updated



insert

int snippet.insert( array data )

Inserts a new snippet into a folder.

Parameters

data

Name

Required

Type

Description

name

yes

string

What you want to name the snippet

folder_id

yes

int

The folder in which the snippet should be placed

Return Values

Returns an int type. The id of the newly created snippet.



update

bool snippet.update( int snippetId, array data )

Updates an existing snippet using the data specified.

Parameters

data

See #insert, however all keys are optional

Return Values

Returns a bool. True on success.



copy

int snippet.copy( int snippetId, string name, int destinationFolderId )

Copy an existing snippet to a new folder/name.

Parameters

snippetId

ID of the snippet to be copied.

name

Name of the new snippet.

destinationFolderId

ID of folder where the new snippet should be created.

Return Values

Returns an int type. The id of the newly created snippet.



delete

bool snippet.delete( int snippetId )

Deletes the specified snippet.

Parameters

snippetId

ID of the snippet you want to delete.

Return Values

Returns true on success, false on failure.



Deprecated

This method has been deprecated and will be removed in a future version. For an alternative, see storeContent()

setContent

bool snippet.setContent( int snippetId, string type, string source, array options )

Sets the snippet content

Parameters

See #storeContent

Return Values

Returns true on success, false on failure.



storeContent

array snippet.storeContent( int snippetId, string type, string source, array options )

Sets the snippet content.

Parameters

snippetId

ID of the snippet you want to update.

type

The content type to update. Can be 'html' or 'text'.

source

Specify the source of the content. Available options:

Source

string

uri

fileupload

options

Associative array of content options:

Key

Type

Value

Note

content

string

snippet content

optional, for use with source=string

uri

string

URI accessible to Maxemail to load as content

optional, for use with source=uri

key

string

key returned from the File_Upload service

optional, for use with source=fileupload

encoding

string


optional, defaults to 'UTF-8'

lineendings

boolean


optional, will convert line endings to default system type, for use with type=text

Return Values

Returns an array of validation warning messages.

Any errors would be handled as exceptions in the usual way for the API.



getContent

string snippet.getContent( int snippetId, string type )

Gets the snippet content.

Parameters

snippetId

ID of the snippet from which you want the content.

type

The content type to update. Can be 'html' or 'text'.

Return Values

Returns the content string.

Service

snippet

Methods