API reference: Content handling documents the function signatures, parameters, return values, and error behavior of the Elaine HTTP API.
Function availability depends on the Elaine release and enabled features. Authenticate HTTP requests with an Elaine-issued Bearer JWT.
Function overview
| integer | api_articleCreate ( string $content , string $subject = '' , bool $use_parser = true , string $mimetype = 'text/plain' , string $charset = 'utf-8' , bool $visible = true ) |
| Creates a new article and returns its ID. |
| integer | api_compositionCreate ( string $subject , array $parts , bool $copyparts = false , bool $condition = false ) |
| Creates a composition with the specified subject from the article transferred as ID array $parts. |
| integer|boolean | api_compositionImport ( string $subject , string $content , bool $rewrite_links = true , bool $insert_trackimage = true , string $base_url = '' , string $link_category = '' , string $charset = 'utf-8' ) |
| Creates a new composition from the transferred subject and composition source code and returns its ID. |
| integer | api_compositionImportUrl ( string $url , string $subject , bool $rewrite_links = true , bool $insert_trackimage = true , string $base_url = '' , string $link_category = '' , string $charset = 'utf-8' ) |
| Generates a mailing from the transferred URL. |
| array | api_getArticleDetails ( int $part_id ) |
| Delivers an associative array with detailed information on a transferred article ID. |
| array|integer | api_getArticleList ( int $cat_id , int $show = 1 ) |
| Delivers an array of all articles saved in the specified folder. |
| array|integer | api_getFolders () |
| Delivers an array of the article folders created for the current tenant. |
| string | api_userParseText ( string $text = '' , int $p_id ) |
| Personalises the transferred text and returns it. |
Functions
api_articleCreate
integer api_articleCreate( string $content , string $subject = '' , bool $use_parser = true , string $mimetype = 'text/plain' , string $charset = 'utf-8' , bool $visible = true )
Creates a new article and returns its ID. Additionally to (plain text or html) content, you can specify the name, mime type and charset encoding. If $use_parser is activated, the input text will be handled as with a classic ELAINE import, i.e. with link rewriting and track image integration, if required. The parameter $show controls if the part is also displayed in the ELAINE interface.
Parameters
| string | $content | Content for article |
| string | $subject = '' | Subject for article |
| bool | $use_parser = true | Parse the content |
| string | $mimetype = 'text/plain' | Mimetype of content |
| string | $charset = 'utf-8' | Charset of content |
| bool | $visible = true | Article visibility |
Return Value
| integer | New ID of article or error code |
api_compositionCreate
integer api_compositionCreate( string $subject , array $parts , bool $copyparts = false , bool $condition = false )
Creates a composition with the specified subject from the article transferred as ID array $parts. If the parameter $copyparts is activated, the articles will also be copied to the article folder. If an array is transferred as parameter $condition, a condition term, which can be included in the composition, can be delivered for each transferred part (as array key).
Parameters
| string | $subject | Subject for composing |
| array | $parts | Parts for composing |
| bool | $copyparts = false | Copy or link? |
| bool | $condition = false | Must be an array with part ids as Keys and the condition(as string) as value |
Return Value
| integer | ID of new composing |
api_compositionImport
integer|boolean api_compositionImport( string $subject , string $content , bool $rewrite_links = true , bool $insert_trackimage = true , string $base_url = '' , string $link_category = '' , string $charset = 'utf-8' )
Creates a new composition from the transferred subject and composition source code and returns its ID. The source code must contain at least one part wrapped with a [part] tag.
Sample source code:
[part mime(html) id(0)] <b> This is a HTML-sample code</b> [/part] [part mime(text) id(0)] This is a plaintext sample [/part] [part mime(html) condition(c_gender=m) id(0)] <i>This is a sample article with individualizing (condition).</i> [/part]
As the source code can be taken from the Elaine instance itself, parts may already contain ID information (as seen in the example). However, this will not be taken into account during the import and can be left out.
You can parametrise the import of content in the interactive import dialogue. You can specify, whether found links should automatically be replaced by tracking links, whether an image tracker should be inserted, whether relative links should be changed into absolute links by means of a base URL, whether a default link category is to be configured and in which charset you wish to provide content. Generally, we recommend to deliver content directly in the internally used charset UTF-8.
Parameters
| string | $subject | Subject of mail |
| string | $content | Content of mail |
| bool | $rewrite_links = true | Bool wether the importer should automatically rewrite links into tracked links, default true |
| bool | $insert_trackimage = true | Bool wether to add a trackimage or not, default true |
| string | $base_url = '' | String basic url for relative urls |
| string | $link_category = '' | String tagname of the basic link category if not set already |
| string | $charset = 'utf-8' | String name of the charset to be used, default: automatic, checks for charset itself |
Return Value
| integer|boolean | ID of created newsletter or false |
api_compositionImportUrl
integer api_compositionImportUrl( string $url , string $subject , bool $rewrite_links = true , bool $insert_trackimage = true , string $base_url = '' , string $link_category = '' , string $charset = 'utf-8' )
Generates a mailing from the transferred URL. The function imports the source code from the given URL and performs according to the api_compositionImport().
Parameters
| string | $url | URL of the source to import |
| string | $subject | Subject of mail |
| bool | $rewrite_links = true | Wether the importer should automatically rewrite links into tracked links, default true |
| bool | $insert_trackimage = true | Wether to add a trackimage or not, default true |
| string | $base_url = '' | Basic url for relative urls |
| string | $link_category = '' | Tagname of the basic link category if not set already |
| string | $charset = 'utf-8' | Name of the charset to be used, default: automatic, checks for charset itself |
Return Value
| integer | $nl_id ID of created newsletter or false |
api_getArticleDetails
array api_getArticleDetails( int $part_id )
Delivers an associative array with detailed information on a transferred article ID. The following information will be returned: 'id', 'title', 'content', 'mime', 'category', 'show', 'template'
Parameters
Return Value
| array | Details of the article |
api_getArticleList
array|integer api_getArticleList( int $cat_id , int $show = 1 )
Delivers an array of all articles saved in the specified folder. Articles on the main layer can be called up by entering the folder ID 0. Optionally, you can access articles, whose output is suppressed in the interface ($show=0: only hidden, $show=2: visible and hidden). An array will be returned with elements as associative arrays with the keys 'id', 'title', 'content' and 'mime'.
Parameters
| int | $cat_id | Holds the id of the category to show, 0 means no category |
| int | $show = 1 | 1 means just show parts that are shown in the frontend; 0 means get hidden parts, 2 means get shown and hidden parts |
Return Value
| array|integer | Array with every part and information to each part (id, title, content, mime) |
array|integer api_getFolders ()
Delivers an array of the article folders created for the current tenant. The individual array elements are associative arrays with the keys 'id' and 'name' of the relevant folder.
Return Value
| array|integer | Folders of current tenant |
api_userParseText
string api_userParseText( string $text = '' , int $p_id )
Personalises the transferred text and returns it. Replaces tags (e.g. [c_email]), but not links, i.e. tracking based on this text is not possible.
Parameters
| string | $text = '' | Text to parse |
| int | $p_id | ELAINE profile ID |
Return Value