This is the web service file _ws.php
<?php
/*
Title: Hello World Example.
Tagline: Let's say hello!.
Description: Basic hello world example to get started with Restler 2.0.
Example 1: GET say/hello returns "Hello world!".
Example 2: GET say/hello/restler2.0 returns "Hello Restler2.0!".
Example 3: GET say/hello?to=R.Arul%20Kumaran returns "Hello R.Arul Kumaran!".
*/
require_once '../restler/restler.php';
require_once 'news_class.php';
$r = new Restler();
$r->addAPIClass('news');
$r->handle();
这是具有以下功能的类文件:
<?php
class news {
function hello($to='world') {
return "Hello $to!";
}
function listnews($page=0){
$result = "";
$xml_doc = new DOMDocument;
$xml_doc->load('news.xml');
$xsl_doc = new DOMDocument;
$xsl_doc->load('news_list.xsl');
$xsl_proc = new XSLTProcessor();
$xsl_proc->importStyleSheet($xsl_doc);
$xsl_proc->setParameter('', 'page', $page);
$result = $xsl_proc->transformToXml($xml_doc);
return $result;
}
} // news -
如果我将 listnews 函数命名为 listNews,则会收到以下错误:
{
"error": {
"code": 404,
"message": "Not Found"
}
}
只要名称现在混合大小写,它就可以工作。是不是应该是这样的?有没有办法使用骆驼肠衣?
谢谢!