我有一个使用 D7 服务模块定义的 REST 端点。我已启用服务和 CRUD 操作。我已启用权限。当我点击端点 /myservice 的 url 时,我收到一条消息
Services Endpoint "myservice" has been setup successfully.
当我点击 /myservice/create (这是我启用的 Create CRUD 服务)时,我只是得到一个空白页,尽管下面的回调有一个打印语句。
。模块
function myservice_permission() {
return array('create constructs' => array(
'title' => t('create constructs'),
'description' => t('Receive messages'),
)
);
}
function _myservice_access($ops, $args) {
return TRUE;
}
function myservice_services_resources() {
return array(
'myservice_messages' => array(
'create' => array(
'help' => 'Creates messages',
'callback' => '_myservice_create',
'access callback' => '_myservice_access',
'access arguments' => array('create constructs'),
'access arguments append' => FALSE,
'args' => array(
array(
'name' => 'data',
'type' => 'struct',
'description' => '',
'source' => 'data',
'optional' => TRUE,
),
),
),
);
}
function _mymodule_create($data) {
print '***here';
}
function myservice_services_endpoint() {
$endpoints = array();
$endpoint = new stdClass();
$endpoint->disabled = FALSE;
$endpoint->api_version = 3;
$endpoint->name = 'myservice';
$endpoint->server = 'rest_server';
$endpoint->path = 'myservice_message';
$endpoint->authentication = array();
$endpoint->server_settings = array();
$endpoint->resources = array(
'myservice' => array(
'operations' => array(
'create' => array(
'enabled' => '1',
),
),
),
);
$endpoint->debug = 1;
$endpoints[] = $endpoint;
return $endpoints;
}
在服务管理面板中,我启用了资源和 crud 操作。
我应该问一件事:有 4 个命名项,端点、资源、服务和端点路径。都必须有不同的名字吗?