Skip to content

API Entry

Compatibility

  • EE2
  • EE3
  • EE4
  • EE5
  • EE6
  • EE7

Installation

The Auth API comes natively with Webservice module.

Methods

create_entry

Short nameDescription
channel_nameThe name of the channel where the entry must be insertedRequired
titleThe title for the entryRequired
statusThe status of the entryOptional
allow_commentsAllow comments?Optional
stickyIs the entry sticky?Optional
custom_fieldsAny custom fields can be addedOptional
categoryarray of category idsOptional
member_idmember_idOptional, otherwise this is the logged user

Request

Array
(
  [status] => Closed
  [title] => Test entry
  [sticky] => y
  [allow_comments] => n

  //custom fields
  [news_body] => This is a full body text
  [news_extended] => This is some small text
  
  [category] => Array(
    1,2,3,4
  )
  
  [custom_file_field] => Array(
  	'filedata' => base64_encode(file_get_contents('path_to_image.jpg')),
	'filename' => 'filename.jpg',
	'dir_id' => 6
  )
)

read_entry

See search_entry method because of v3.5 they are the same

update_entry

Short nameDescription
entry_idThe entry ID of the entry that you are going to updateRequired
search[]You can also identify the entry with a search param (See https://docs.reinos.nl/webservice/#search-mechanism)Required
titleThe title for the entryOptional
statusThe status of the entryOptional
allow_commentsAllow comments?Optional
stickyIs the entry sticky?Optional
custom_fieldsAny custom field(s)Optional
categoryarray of category idsOptional
member_idmember_idOptional, otherwise this is the logged user

Request with ENTRY_ID

Array
(
  [entry_id] => 1
  [status] => Closed
  [title] => Test entry
  [sticky] => y
  [allow_comments] => n

  //custom fields
  [news_body] => This is a full body text
  [news_extended] => This is some small text
)

Request with SEARCH When you are using the search param, The webservice will return an error if multiple errors are found. To ignore this error you can use the force param.

Please note that updating by Entry_id is safer, but it will cost you an extra request.

Array
(
  [search] => Array
  (
    [custom_field] => =test // = sign is for an explicit search. See the https://docs.reinos.nl/webservice/#search-mechanism for more info
    [force] => true // marked that in case of mulitple entries, you will update the first one.
  )
  [status] => Closed
  [title] => Test entry
  [sticky] => y
  [allow_comments] => n

  //custom fields
  [news_body] => This is a full body text
  [news_extended] => This is some small text
)

delete_entry

Short nameDescription
entry_idThe entry IDRequired

Request

Array
(
    [entry_id] => 14
)

search_entry

Note: the order of the request will be the order of the query

Short nameDescription
channelIf you use only the channel_name you wil get all entries in this channelOptional
channel_idSearch on Channel IDOptional
limitThe limit, can be used in conjunction with the offsetOptional
offsetthe offset, can be used in conjunction with the limitOptional
custom_fieldsany other custom fieldOptional
orderbysorting data based on a fieldOptional
sortset the sortOptional
entry_idIf selecting just one entry by entry_idOptional
url_titleSearch on an URL TitleOptional
statusThe status of an entryOptional
grid_field/matrix_fieldSearch in any grid/matrix field with the regular searchOptional
grid_field[col_name]/matrix_field[cell_name]Search in any grid/matrix cell where you can search on an exact col_name/cell_name with the use of the search mechanism belowOptional
output_fieldsspecify the field to output (applied also on the relationships)Optional
search_allMagic keyword that will search in all entry custom fieldsOptional
start_ongive a date to start fromOptional
stop_beforegive a date to stop beforeOptional
cat:[field_name]search on category fields (values are cat_id group_id cat_name cat_url_title your_custom_field)Optional
includeinclude more data in the result data[include]=channel|categories|authorOptional
returnTo return only the stats, use this param data[return]=metaOptional

Search mechanism

Basic
TypeOperatorExample
Contains<empty>data[body]=test
Contains with wildcard<empty>data[body]=~test what result in %test
Contains NOT<empty>data[body]=not test
"Exact" Matching=data[body]==test
Numeric Matching< > <= >=data[body]=>10
Including / Excluding Empty FieldsIS_EMPTYdata[body]=IS_EMPTY
Including / Excluding Empty Fields NOTIS_EMPTYdata[body]=not IS_EMPTY
OR / AND

By default we build the query with AND. To change this to OR, simply add or to a value.

data[title]=or john
Multiple values

To use multiple values for a field, just use a pipeline | or a comma ,

AND values for the same field are not possible due EE limitation

data[title]=test|john

will be in MySQL

title = 'test' OR title = 'john'
Groups

You can also using to group values together like you can do in a normal Database query (field_1 = '4' OR field_1 = '5') AND (field_1 = '2' OR field_1 = '3'')'

AND values for the same field are not possible due EE limitation

Group name can be anything, it should be unique so you can create multiple groups

Request group

data[group_one_name_just_pick_one][group_and][][title]=test|john&ata[group_two_name_just_pick_one][group_and][][title]=willem|doe
(title = 'test' OR title = 'john') AND (title = 'willem' OR title = 'doe')

Request

Array
(
  [channel] => news_channel
  [limit] => 25
  [offset] => 5
  [start_on] => 01-01-2015
  [stop_before] => 31-12-2015
)
Array
(
  [channel] => news_channel
  [limit] => 25
  [offset] => 5
  [start_on] => 01-01-2015
  [stop_before] => 31-12-2015
  [group_and] => Array
  (
    [group_title] => Array
    (
        [0] => Array
        (    
            [title] = john,doe       
        )
    )
  )
)

Hooks

webservice_create_entry_start

(added in v3.2.1)

$entry_data = ee()->extensions->call('webservice_create_entry_start', $entry_data);

webservice_create_entry_end

(added in v2.2)

ee()->extensions->call('webservice_create_entry_end', $entry_id, $post_data);

webservice_read_entry_start

(added in v3.2.1)

$entry_data = ee()->extensions->call('webservice_read_entry_start', $entry_data);

webservice_read_entry

(added in v4.4.2)
Runs after the validation

$entry_data = ee()->extensions->call('webservice_read_entry', $entry_data, $post_data);

webservice_read_entry_end

(added in v2.2)

$entry_data = ee()->extensions->call('webservice_read_entry_end', $entry_data);

webservice_update_entry_start

(added in v3.2.1)

$entry_data = ee()->extensions->call('webservice_update_entry_start', $entry_data);

webservice_update_entry

(added in v4.4.2)
Runs after the validation

$entry_data = ee()->extensions->call('webservice_update_entry', $entry_data, $post_data);

webservice_update_entry_end

(added in v2.2)

ee()->extensions->call('webservice_update_entry_end', $entry_data, $post_data);

webservice_delete_entry_start

(added in v3.2.1)

$entry_data = ee()->extensions->call('webservice_delete_entry_start', $entry_data);

webservice_delete_entry_end

(added in v2.2)

ee()->extensions->call('webservice_delete_entry_end', '');

(added in v4.0)
With this hook you can extend the search by your own. Just make sure the hook will return an array of entry_ids.

$entry_ids = ee()->extensions->call('webservice_search_entry_per_entry', $values, $fields);

webservice_search_entry_per_entry

(added in v3.2)

$entry_data = ee()->extensions->call('webservice_search_entry_per_entry', $entry_data);

webservice_search_entry_per_entry

(added in v3.2)

$entry_data = ee()->extensions->call('webservice_search_entry_per_entry', $entry_data);

webservice_search_entry_start

(added in v3.2.1)

$entry_data = ee()->extensions->call('webservice_search_entry_start', $entry_data);

webservice_search_entry_end

(added in v2.2)

$entry_data = ee()->extensions->call('webservice_search_entry_end', $entry_data);

webservice_entry_row

(added in v3.5)
WIll be called when reading an entry

$entry_data = ee()->extensions->call('webservice_entry_row', $entry_data);

webservice_read_entry_matrix

(added in v4.0)

ee()->extensions->call('webservice_read_entry_matrix', $value, $col_settings);

webservice_read_entry_grid

(added in v4.0)

ee()->extensions->call('webservice_read_entry_grid', $value, $col_settings);

Examples

Create entry SOAP

<?php

//file data
$image = 'file.jpg';
$file = base64_encode(file_get_contents($image));

$client = new SoapClient('http://domain.com/index.php/webservice/soap?wsdl', array('trace' => 1));

$reponse = $client->create_entry(array(
	'username' => 'testUsername',
	'password' => 'testPassword'
), array(
	'channel_name' => 'news',
	'status' => 'Open',
	'title' => 'test entry',
	'sticky' => 'y',
	'allow_comments' => 'n',
	'category' => '1|2|3',
	'filefield' => array(
		'filedata' => $file,
		'filename' => 'file.jpg',
		'dir_id' => 6
	)
));
?>

Create entry REST (with an image)

<?php
$url = 'http://domain.com/index.php/webservice/rest/create_entry';

//set POST variables
$fields = array(
	'auth' => array(
		'username' => 'admin',
    	'password' => 'test123',
	),
	'data' => array(
		'channel_name' => 'test_channel',
		'title'	=> 'Test entry',
	)
);

//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, urldecode(http_build_query($fields)));
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);

?>

Create entry XMLRPC

<?php
//http://gggeek.github.io/phpxmlrpc/
include("xmlrpc/xmlrpc.inc");

$c = new xmlrpc_client('http://domain.com/index.php/webservice/xmlrpc');

$x = new xmlrpcmsg('create_entry', array(
	php_xmlrpc_encode(array(
		'username' => 'admin',
		'password' => 'test123',
	)),
	php_xmlrpc_encode(array(
		'channel_name' => 'test_channel',
		'title'	=> 'Test entry',
	)),
));

$c->return_type = 'phpvals';
$r =$c->send($x);
?>