Last updated September 26, 2012. Created by agungsuyono on September 25, 2012.
Edited by jackbravo. Log in to edit this page.
For example you have an exported service endpoint like this:
<?php
$endpoint = new stdClass;
$endpoint->disabled = FALSE; /* Edit this to true to make a default endpoint disabled initially */
$endpoint->api_version = 3;
$endpoint->name = 'test';
$endpoint->server = 'rest_server';
$endpoint->path = 'test';
$endpoint->authentication = array();
$endpoint->server_settings = array();
$endpoint->resources = array(
'node' => array(
'operations' => array(
'retrieve' => array(
'enabled' => 1,
),
'create' => array(
'enabled' => 1,
),
'update' => array(
'enabled' => 1,
),
'delete' => array(
'enabled' => 1,
),
'index' => array(
'enabled' => 1,
),
),
'relationships' => array(
'files' => array(
'enabled' => 1,
),
'comments' => array(
'enabled' => 1,
),
),
),
);
$endpoint->debug = 0;
?>and you want to put that exported service endpoint to a certain module (for example mymodule) so that when that module is installed in a different site, that exported service endpoint is already available on the Service page (in drupal 6 it is at admin/build/services/list).
To do that, in your mymodule.module, put the following hook:
<?php
/**
* Implementation of hook_ctools_plugin_api().
*/
function mymodule_ctools_plugin_api($module, $api) {
if ($module == 'services' && $api == 'services') {
return array('version' => 3);
}
}
?>And then, create a file named mymodule/mymodule.services.inc, inside that file, put your exported service endpoint:
<?php
function mymodule_default_services_endpoint() {
$export = array();
// begin exported service endpoint.
$endpoint = new stdClass;
$endpoint->disabled = FALSE; /* Edit this to true to make a default endpoint disabled initially */
$endpoint->api_version = 3;
$endpoint->name = 'test';
$endpoint->server = 'rest_server';
$endpoint->path = 'test';
$endpoint->authentication = array();
$endpoint->server_settings = array();
$endpoint->resources = array(
'node' => array(
'operations' => array(
'retrieve' => array(
'enabled' => 1,
),
'create' => array(
'enabled' => 1,
),
'update' => array(
'enabled' => 1,
),
'delete' => array(
'enabled' => 1,
),
'index' => array(
'enabled' => 1,
),
),
'relationships' => array(
'files' => array(
'enabled' => 1,
),
'comments' => array(
'enabled' => 1,
),
),
),
);
$endpoint->debug = 0;
// end of exported service endpoint.
$export['test'] = $endpoint;
return $export;
}
?>Your service endpoint should be automatically listed in Service page once mymodule is installed.