badVersion nightmares

sinisterV - July 23, 2009 - 17:45
Project:AMFPHP
Version:6.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

i know i must sound like a broken record, as i have seen requests like this all over the net. but i cannot get past this error.
I have the service modules setup correctly, i get to the OK screen for AMFPHP in the services section.
i have all the proper modules installed.
i am running amfphp 1.9 beta2.

i have used three separate examples of the Drupal connection actionscript. each pretty much doing the same thing, using the netConnection to connect to the service. I have "handled" the netStatus Error which will get rid of the error, but it halts the as code and doesn't trace anything after that. which should be tracing back my content(as seen in the onConnect events trace statements). Please see the code i am working with and if anyone can shed some effective light on the solution i would be greatly indebted. The code i am working with is below.

import flash.display.MovieClip;
import Drupal;

public class Main extends MovieClip {

private var _var1:Number;
private var dru:Drupal;

public function Main():void {

init();
}

private function init():void {

setUpDrupal()
}

private function setUpDrupal() {

dru = new Drupal();

dru.gatewayUrl = 'http://localhost:8888/site1/modules/amfphp/amfphp/gateway.php'; //this is the url of your amfphp service responder
//dru.gatewayUrl = 'http://localhost:8888/site1/?q=services/amfphp'
dru.apiKey = "63cb056c8849b328686c4effbb40dcc0"; // this is the api key from inside drupal

dru.connect(onConnection);
}

private function onConnection() {

trace("gettinghere");
dru.service(getArticles, onFault, "views.get", "pages");

}

private function onFault(e:Error) {

trace("there has been an error "+e);

}

private function getArticles(result:Object) {

      for(var prop in result) {

           trace("title is "+prop.title);

           trace("body is "+prop.body);
       }

}

package {

import flash.net.Responder;
import flash.events.NetStatusEvent;
/*
* Drupal class for AMFPHP connections to Drupal services
*/
public class Drupal {

public var gatewayUrl:String = "";
public var apiKey:String = "";
public var sessionId:String = "";

private var rs:RemotingService;

private var callback:Function;

/*
* Drupal.connect()
*/
public function connect(onSuccess:Function):void {
callback = onSuccess;
this.service(onConnect, onFault, 'systems.connect');
//this.service(onConnect, onFault, 'views.get');
}

/*
* Drupal.service(onSuccess, onFault, command, ... args)
*/
public function service(onSuccess, onFault, command, ... args):Boolean {
if (gatewayUrl.length > 0) {
rs = new RemotingService(gatewayUrl);
rs.addEventListener(NetStatusEvent.NET_STATUS,netHandler);

}
else {
return false;
}

var responder:Responder = new Responder(onSuccess, onFault);

if (sessionId.length > 0) {
args.unshift(sessionId);
}
if (apiKey.length > 0) {
args.unshift(apiKey);
}

if (args.length==1) {
rs.call(command, responder, args[0]);
}
else if (args.length==2) {
rs.call(command, responder, args[0], args[1]);
}
else if (args.length==3) {
rs.call(command, responder, args[0], args[1], args[2]);
}
else if (args.length==4) {
rs.call(command, responder, args[0], args[1], args[2], args[3]);
}
else if (args.length==5) {
rs.call(command, responder, args[0], args[1], args[2], args[3], args[4]);
}
else if (args.length==8) {
rs.call(command, responder, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
}

return true;
}

public function netHandler(event:NetStatusEvent):void {
trace("no 2044 error");
//trace(event.type)
}

/*
* private functions
*/
private function onConnect(result:Object):void {
trace("gettoconnect");
sessionId = result.sessid;
if (callback is Function) {
callback();
}
}

private function onFault(error:Object):void {
trace('ERROR:drupal.Drupal:netconnection:');
for each (var item in error) {
trace(item);
}
}

}

}

/*
* RemotingService for AMFPHP connection in AS3
*/
import flash.net.NetConnection;
    import flash.net.ObjectEncoding;


class RemotingService extends NetConnection {

function RemotingService(url:String) {
// Set AMF version for AMFPHP
objectEncoding = ObjectEncoding.AMF3;
// Connect to gateway
connect(url);
}

}

#1

sinisterV - July 24, 2009 - 16:04

well i have gotten past my badVersion nightmare.. i had some bad characters in my gateway.php file.

but,. now i am stumped as to how to access the system.connect class properly. i hacked my way through it so far by manually writing a class with that name and putting it in the amfphp/services folder. but i am feeling this is not the way to do it. as all the examples i've seen have not mentioned having to do this at all.
Am i getting to the right place? all the examples i see don't actually point tot he gateway.php file like i do above, they all look something like this, services/amfphp.

I am sensing i have a fundamental misunderstanding of what "service" i should be actually talking with from flash. Shouldn't the service class just be located somewhere within drupal, when the services modules are enabled????,,,, i am feeling like quite a noob right now, and i need desperately to figure this out...

Thanks

 
 

Drupal is a registered trademark of Dries Buytaert.