I am using this module together with Services 6.x.2.2 and the most recent AMFPHP library. I am trying going through some basic examples in the Flash CS4 IDE. I can create connection, get a session id and extract node data. I have created a view that simply lists all the nodes on the site (currently 3) but I only get the first node from the view. I can extract everything about that node but it's as if the other nodes didn't exist. I checked in the services browser and it returns the correct information. If somebody could help me solve this I would be really grateful. I've been troubleshooting this for most of the past week. My actionscript3 code is below
var drupal:NetConnection = new NetConnection();
drupal.objectEncoding=flash.net.ObjectEncoding.AMF3;
drupal.connect("http://mySite.com/services/amfphp");var responder:Responder=new Responder(onReturn,onError);
drupal.call("system.connect",responder);//SYSTEM CONNECTION + SESSION ID EXAMPLE
var sessionId:String="";function onReturn(result:Object) {
sessionId=result.sessid;
trace("Session ID = "+sessionId);
loadView();}
function onError(error:Object) {
trace("Error = "+error);
}// THIS EXAMPLE LOADS A VIEW.
function loadView( vname:String = "sitemap" ) {
// Set up our responder with the callbacks.
var viewsResponse:Responder=new Responder(onViewLoad,onError);
// Call Drupal to get the node.
drupal.call( "views.get", viewsResponse, sessionId, vname);
}// Called when Drupal returns with our node.
function onViewLoad( view:Object ) {
var tmpLength:int = 0;// Print out the view.
trace("View Loaded");
trace("view.length = "+view.length);
// Iterate through all of the nodes.
for each (var node:Object in view) {
tmpLength++;
trace("tmpLength = "+tmpLength);
trace( "node #"+node.nid );
trace( "node type = "+node.type );
trace( "title = "+node.title );
trace( "body = "+node.body );
}
}
Comments
Comment #1
autodidactic commentedUPDATE: I've tried different versions of services to no avail. I have just discovered that node.get will only return data for the first node (nid = 1). If I try to do a node.get for nodes with an id of 2 or greater, I get an error in flash (everything is ok in the services browser on the admin page)
Comment #2
autodidactic commentedSOLVED: I was testing from the flash IDE connecting to a remote server. Putting the compiled .swf on the remote server solved the problem.