Services module uses session ID instead of node ID when node.get is called by Flash

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
LuckyBamboo's picture

Hi
I'm trying to use the services module to connect Flash to Drupal. I followed some examples I found online as well as the example included in the book "Flash with Drupal".

I can connect to Drupal via Flash and get my Session ID but for the life of me I can't get the node.get call to work. I keep getting the error message: "Could not find the node".

Here is how I call node.get to try and get node 1 (which of course does exist!)

var nodeResponse:Responder = new Responder ( onNodeLoad, onError)
// call Drupal to get node
drupal.call("node.get", nodeResponse, sessionID, 1);

I used drupal's watch dog function to try and get some clues as to what is going wrong. What i found is that the function node_service_get($nid, $fields = array()) is receiving the sessionID variable as it's first argument. the last parameter 1 (int) is passed into $fields[0].

I also used the watchdog function inside of the function amfphp_method_call($method_name, $args) located inside of amfphp.inc. The values passed into the arguments:

$method_name=node.get
$args[0] = 18e7e05064hfdunfda31hufkn1 (my session ID)
$args[1] = 1

I couldn't find any mention of this issue anywhere except for this single post that seems to be about this issue yet it has not been resolved:
http://drupal.org/node/519078

I will really appreciate any kind of help here.
TIA!

Comments

Sorry for the basic question,

waldmanm's picture

Sorry for the basic question, but do you have "Use sessid" option checked in Services Settings? If not, then the server would not expect it as the first argument, which fits your description of what's happening.

BTW, Rolf's recommendation in the post you reference above is a good one (and he should know as he developed it ...).

Hi, whenever you are using

rolf vreijdenberger's picture

Hi, whenever you are using sessions, you should call system.connect first to get a valid anonymous session Id.

furthermore, it seems that something is either not sent or configured correctly.

When sessions are enabled, the services module will take care of the sessionID argument for you, and then pass the nodeId to the node.get method.

So either
- configure the backend to use sessions and do a call to system.connect first to get a valid sessionId
or
- don't use sessioins
or
- make sure the parameters are sent correctly.

As said by waldmann, I developed the DrupalProxy (http://www.dpdk.nl/opensource) and this will make life much easier for you when programming as3 and drupal services :)
It will handle the sessions and authentication issues automatically without you having to write hard code.
Try it out

Kind regards,

Rolf Vreijdenberger

drupal and flash: http://www.dpdk.nl/opensource/drupalproxy-as-a-bridge-between-flash-as3-...

Services

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: