After going back over the screen-casts available on the Services group using Drupal 6 to start writing custom services I discovered that the custom "recipe_service" module example would return node id's (nids) in an array form and no actual content.

Heres how it went in the recipe_service.module:
function recipe_service_all($fields = array()) {
$result = db_query("SELECT nid FROM {node} WHERE type='recipe'");

$nodes = array();
while ($node = db_fetch_object($result)) {
$nodes[] = services_node_load(node_load($node), $fields);
}

return $nodes;
}

Outcome:

Array
(
[0] =>
[1] =>
[2] =>
[3] =>
)

Take out the "node_load" inside the "services_node_load" array and I get this:
function recipe_service_all($fields = array()) {
$result = db_query("SELECT nid FROM {node} WHERE type='recipe'");

$nodes = array();
while ($node = db_fetch_object($result)) {
$nodes[] = services_node_load($node, $fields);
}

return $nodes;
}

Outcome now:

Array
(
[0] => stdClass Object
(
[nid] => 1
[body] => n/a
[body_value] =>
)

[1] => stdClass Object
(
[nid] => 2
[body] => n/a
[body_value] =>
)

[2] => stdClass Object
(
[nid] => 3
[body] => n/a
[body_value] =>
)

[3] => stdClass Object
(
[nid] => 4
[body] => n/a
[body_value] =>
)

)

It's closer to what I want but it needs to spit out the information contained in the nodes, but don't think the function is looping over the right arrays. Been looking over the code but I'm not sure where to go with it now?
BeechyBoy

Comments

JoachimVdH’s picture

Title: Broken in Drupal 6 » Broken in Drupal 6 (services-views error)
Version: 5.x-1.x-dev » master

For the cause of testing amfphp for dr6, I watched the tutorial and created everything step by step.
Where it goes wrong at the moment is the communication between the services and views.
When you load views.getviews from the services menu, you see the error.

Fatal error: Call to undefined function views_build_view() in .../drupal6/sites/all/modules/services/services/views_service/views_service.module on line 57

Fatal error: require_once() [function.require]: Failed opening required 'sites/all/modules/views/includes/plugins.inc' (include_path='.:/usr/lib/php/extensions') in .../drupal6/sites/all/modules/views/views.module on line 249

Views is still being build, so i assume the services will connect on the right way with views when views is stable. ( and views services is modified to the new way of working with views)

so i think we have to be patient.

module versions:

  • Services 6.x-1.x-dev (2008-Jan-25)
  • Views 6.x-2.0-alpha2

Joachim

jody lynn’s picture

Project: AMFPHP » Services
Version: master » 6.x-1.x-dev

This is a result of a change in services module not amfphp.

carvalhar’s picture

so...i'm having the same problem....

is it working today?
almost one year after...

where do i get info about services functions?

thanks

snelson’s picture

Assigned: Unassigned » snelson
Category: bug » support
Priority: Critical » Normal
Status: Active » Fixed

Try changing:

$nodes[] = services_node_load(node_load($node), $fields);

to:

$nodes[] = services_node_load(node_load($node->nid), $fields);

Should do it.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.