サービス モジュールで直接取得する方法がない場合は、独自のカスタム モジュールを作成して hook_services_resources を実装することで、ノードとそのコメントを取得する方法があります。このフック メカニズムは、drupal メニュー フックに似ています。
これは drupal 7 で書かれたコード スニペットですが、drupal 6 でも動作するはずです。
Url : <drupal site>/<REST server endpoint>/my_rest_api/<node id>.json
それがうまくいくかどうか私にさせてください。さもなければ、D6 でモジュール全体を作成してここに貼り付けます。
/**
* Implements hook_services_resources().
* my_rest_api should appear in your resource list and do enable it before using it.
*/
function YOURMODULE_services_resources() {
return array(
'my_rest_api' => array(
'retrieve' => array(
'callback' => 'getMyRestNodeWithComments',
'args' => array(
array(
'name' => 'nid',
'optional' => FALSE,
'source' => array('path' => 0),
'type' => 'int',
),
),
'access callback' => 'getMyRestAcces',
),
),
);
}
/**
* Get the node along with comment
*/
function getMyRestNodeWithComments($nid) {
$node = node_load($nid);
$node->comments = getMyRestCommentByNid($nid);
return $node;
}
/**
* Access callback.
* TRUE for now but you change it according to your requirement
*/
function getMyRestAcces() {
return TRUE;
}
/**
* Get comment by nid
*/
function getMyRestCommentByNid($nid){
//drupal 7
$query = db_select('comment', 'c');
$comments = $query
->fields('c')
->condition('c.nid', $nid)
->execute()
->fetchAll();
return $comments;
/*
//In Drupal 6 something like this
$result = db_query("select * from {comment} where nid = %d",$nid);
$records = array();
while($row = db_fetch_array($result)){
array_push($records, $row);
}
return $records;
*/
}