AMFPHP Support for JSON POSTs

I found myself wanting to use JSON POSTs (not just GETs) with AMFPHP. Here’s the addition.

Open up core\json\app\Gateway.php.

After

$rawArgs = explode('/', $args);

add the following

if(isset($_POST) && count($_POST) > 0)
{
$len = count($rawArgs);
// Check for and remove [last] empty arg from URL '/' explosion
if($len && trim($rawArgs[$len-1]) == "")
unset($rawArgs[$len-1]);

// Append the POST variables
for($i=0;$i

The format of the post variables would be argNo=value
Ex.
Backend Function

public function ResetPassword($username,$password,$oldpassword)
{
// Code HERE
}

Javascript POST parameters for the latter

request.send("0=" + escape(username) + "&1=" + escape(oldpassword) + "&2=" + escape(newpassword));

Hoping to jump into ZendAMF soon 🙂

What, My Flash Gateway is Already AJAX Ready? Sweet.

I’m integrating existing Flex functionality with some new COTS [AJAX RIA] software. Looks like I’m golden on two fronts:

  1. My existing dashboarding app leverages the dynamic module architecture blogged hear in the past. Each module was cleanly encapsulated so it’s about a dozen lines of code to convert each module into a stand-alone app that integrates w/the AJAX page.
  2. My AMFPHP backend is fully reusable!! Using JSON for my AJAX calls, I can simply hit
    path_to_amfphp_install/json.php/class.package.classname.methodname/arg1/arg2/arg3

I really need to take some time and check out Wayne’s ZendAMF to see what he’s cooked up there, I’ve been far too busy as of late.