RSS
 

AMFPHP Support for JSON POSTs

24 Jul

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 :)

 
No Comments

Posted in JSON

 

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