kennylerma / facebook-actionscript-api

Automatically exported from code.google.com/p/facebook-actionscript-api
0 stars 0 forks source link

AbstractFacebookRequest::objectToURLVariables #372

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Use a typed object as a parameter in Facebook.api() like so:

FacebookMobile.api(
    "/me/friends",
    callback,
    typedParameterObject);

What is the expected output? What do you see instead?

The way AbstractFacebookRequest::objectToURLVariables is written will only work 
with dynamic properties of dynamic objects. If the object is not a dynamic 
Object, but rather a typed value object, no properties will be assigned to 
URLVariables.

Please provide any additional information below.

You should be using describeType instead.

Original issue reported on code.google.com by bmj...@gmail.com on 31 Oct 2011 at 3:23

GoogleCodeExporter commented 9 years ago
Here's an example of how this could be handled better:

private function objectToURLVariables(params:*):URLVariables {
    var vars:URLVariables = new URLVariables();

    // this assignes non-dynamic properties
    var type:XML = describeType(params);
    for each (var prop:XML in type.variable) {
        var propName:String = prop.@name;
        if (null != params[propName]) vars[propName] = params[propName];
    }

    // this assigns dynamic properties
    for (var property:String in params) {
        if (null != params[property]) vars[property] = params[property];
    }

    return vars;
}

Original comment by bmj...@gmail.com on 31 Oct 2011 at 4:07