I have a zend JSON factory that is designed to distribute OTPs for a service, however I cannot get the server to actually return anything..
<?php
class Application_Model_FrogconnectOTP
{
/**
* Generates, stores, and returns the OTP for thesupplied user
*
* @param string $username
* @return string
*/
public function generate($username)
{
$hash = "Lol";
return $hash;
}
/**
* Will clear the OTP for the user.
*
* @param string $username
* @return int
*/
public function delete($username)
{
return 1;
}
/**
* Takes the supplied username and hash and will calculate new sums and verify the supplied hash.
*
* @param string $username
* @param string $hash
* @return int
*
*/
public function validate($username, $hash) {
return 1;
}
}
?>
And this class is loaded by the default(ish) zend json server that looks like the following:
<?php
$this->_helper->layout->disableLayout();
$server = new Zend_Json_Server();
$OTPEngine = new Application_Model_FrogconnectOTP();
$server->setClass($OTPEngine);
if ('GET' == $_SERVER['REQUEST_METHOD']) {
// Indicate the URL endpoint, and the JSON-RPC version used:
$server->setTarget('/frogconnect')
->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
// Grab the SMD
$smd = $server->getServiceMap();
// Return the SMD to the client
header('Content-Type: application/json');
echo $smd;
return;
}
$server->handle();
However if I try to make a request with a json string that looks similar to the following, the server responds with a 204 No Content header, but I receive no content (I should be expecting "Lol"
{"method":"generate","params":{"username":"johndoe"}}
Any help would be appreciated
getServiceMap()return exactly? I mean, using a debugger or justvar_dump()?setHeader()($this->getResponse()->setHeader())?