0

我是restler的新手并尝试做以下事情,似乎无法掌握它

我通过 Restler 公开了这个类和方法

class Account {
    protected $Api_Version = array('version' => "1.0.2.1234", 'href' => "/");
// Returns the version of the service
// Content-Type: application/vnd.cust.version+json
function version() {
return json_encode($this->version);
}

// Accepts only Content Type: application/vnd.cust.account+json
function postCreate() {

}
}

1)我想将我自己的 Content-Type 返回给客户端,就像在“版本”方法中一样,而不是默认的应用程序/json。在我的情况下,它的'application/vnd.cust.version+json'

2) 如果 Contet-Type 设置为 'application/vnd.cust.account+json',方法 postCreate 应该只接受请求。如何检查请求中是否设置了该标头。

3)同样在restler API Explorer中,对于methond名称,我怎样才能只显示方法名称而不是'version.json'。我只想显示“版本”,如方法名称

谢谢您的帮助。纳尔西

4

1 回答 1

0

1)也许写你自己的格式?看看 http://restler3.luracast.com/examples/_003_multiformat/readme.html

2)您可以检查标题并在错误的标题上抛出异常。看看这个链接 http://stackoverflow.com/questions/541430/how-do-i-read-any-request-header-in-php

3)您是否尝试过将以下行添加到您的 Index.php 中?

资源::$useFormatAsExtension = false

希望能带你走得更远:)

铜英格

于 2013-04-03T08:52:20.263 回答