我有一个 zend JSON 工厂,旨在为服务分发 OTP,但是我无法让服务器实际返回任何内容..
<?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;
}
}
?>
这个类由默认(ish)的zend json服务器加载,如下所示:
<?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();
但是,如果我尝试使用类似于以下内容的 json 字符串发出请求,服务器会以 204 No Content 标头响应,但我没有收到任何内容(我应该期待“Lol”
{"method":"generate","params":{"username":"johndoe"}}
任何帮助,将不胜感激