« What, my flash gateway is already AJAX ready? Sweet. - Install WTP in Flex Builder »

AMFPHP Support for JSON POST

24 July 2009

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 $rawArgs[] = $_POST[$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 :)


Leave a reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

cheap generic kamagra kamagra uk viagra! Discount Viagra generic viagra levitra and cialis pills! "));