我已经注册了一项服务,当我调用它时,调用本身有效,但返回的数据是“false”。我不知道我做错了什么,我找不到有关它的信息。有人可以帮帮我吗?
function services_sso_server_extension_services_resources() {
return array(
'mia' => array(
'actions' => array(
'retrieve' => array(
//'help' => 'retrieves the corresponding user on the server',
'file' => array('type' => 'inc', 'module' => 'services_sso_server_extension', 'name' => 'resources/extension'),
'callback' => '_sso_server_retrieve',
'args' => array(
array(
'name' => 'id',
'type' => 'int',
'description' => 'The id of the note to get',
'source' => array('path' => '0'),
'optional' => TRUE,
),
),
'access callback' => '_sso_server_access',
'file' => array('type' => 'inc', 'module' => 'services_sso_server_extension', 'name' => 'resources/extension'),
'access arguments' => array('view'),
'access arguments append' => TRUE,
),
'action' => array(
//'help' => 'retrieves the corresponding user on the server',
'file' => array('type' => 'inc', 'module' => 'services_sso_server_extension', 'name' => 'resources/extension'),
'callback' => '_sso_server_get_action',
'args' => array(
array(
'name' => 'clientsid',
'type' => 'varchar',
'description' => 'The sid of the client to which the communication is bound',
'source' => array('path' => '0'),
'optional' => TRUE,
),
),
'access callback' => '_sso_server_access',
'file' => array('type' => 'inc', 'module' => 'services_sso_server_extension', 'name' => 'resources/extension'),
'access arguments' => array('view'),
'access arguments append' => TRUE,
),
),
),
);
}
我在其他地方使用此代码来调用它:
function services_checkuser() {
global $user;
$sid = $user->sid;
$options = array(
'headers' => array(
'Cookie' => $_SESSION['gsid'],
'Accept' => 'application/json',
'clientsid' => $sid
),
'method' => 'POST',
);
$response = drupal_http_request('http://sso.server:8080/usercheck/mia/action', $options);
$data = json_decode($response->data);
}
答案 0 :(得分:0)
好的,我发现了如何发布数据:
$data = array('gsid' => $gsid);
$options = array(
'headers' => array(
'Cookie' => $_SESSION['broker_sid'],
'Accept' => 'application/json',
),
'method' => 'POST',
'data' => http_build_query($data)
);