AMFPHP Browser syntax for testing services.
The Service Browser uses the remoting gateway to present a list of service classes and their methods. By selecting one of your methods, you will be presented with a page that allows you to call it; by entering arguments and observing the output in the “results” tab below, you can test remoting methods here.
The text inputs for arguments accept arguments in JSON (JavaScript Object Notation) or “object literal” format; essentially, valid ECMAScript (JavaScript/ActionScript) syntax.
String arguments can be entered directly without requiring quote marks, and number arguments can be entered directly as well.
To pass an array as an argument, use the JSON/ECMAScript array literal syntax – comma-separated values between square brackets. For example, if the parameter expects an array of numbers, you would enter it something like:
[1, 3, 5.5, 44]
A two-dimensional array in JSON format is entered as an array of arrays like this:
[[1, 2, 3], [5, 7, 15], [1, 7, 2]] .
Objects (such as VOs) can also be input here, using JSON/ ECMAScript object literal syntax like this:
{id: 1, label: ‘A label’, notes: ‘Some notes’}.
Objects and arrays can also be nested inside each other:
[{id: 1, label: ‘first object’}, {id: 99, label: ‘object with an array in it’, numbers: [13, 44, 97]}, {id: 34, label: ‘object with another object in it’, thing: {‘things’: 14, ‘gadgets’: 6, ‘tchockies’: 0}}]
In addition to numbers and strings, these are all valid types of arguments an AMFPHP remoting method can accept.
For more about JavaScript/ActionScript array-literal syntax and the object/associative-array duality of ECMAScript, consult your friendly neighborhood Internet.
Note that for some reason the service browser does not much care for double-quotes, so when entering object arguments, use the single-quote format for strings.
Also note that currently, although PHP supports optional arguments to a method by specifying a default value in the method signature, the service browser does not have a way to “skip” entering an argument. If you leave an input box blank, the parameter will receive an empty string.


When you pass an object to the service function
like that
function createClient($oDataSub){
return $oDataSub->email;
}
of course this doesn’t work, but how can you make it work, I mean retrieve the email variable from this object?
Do we need to do all the mapping work ? or is there a way to change the syntax of $oDataSub->email to make it work?
I am sure it is a stupid question, but how one can enter a boolean??
true or false doesnt work.
it considers it as string by default.
Hi,
It seems like my comment gets deleted.
i like to know if it is possible to use boolean in anyway, either in the service browser or in the FLex Remote object method call. I am always having problems and end up using string “1″ or “0″ for boolean method variables.
Thanks
Hope that helps someone
The only thing that worked for me (amfphp1.9.20080120):
String example : “mike”
Object example : {“number”:3,”string”:”somestring”}
sniffed in Charles, AMF msg is created properly
marchin
I find you do have to double quote everything – otherwise it comes up as invalid JSON.
But when double quoted, I get the following:
(Object)#0
message = “faultCode:AMFPHP_RUNTIME_ERROR faultString:’AMFPHP Remoting ‘CLASS’ class database UPDATE query error: 1054′ faultDetail:’/home/sites/ws.dom.com/web/amfphp/services/class.php on line 236′”
name = “Error”
rootCause = (null)
So I suspect this is the instance of where it doesn’t like double quotes. But I can’t pass the object as an argument otherwise – it just comes up as invalid JSON……
marchin ’s technique worked for me