[英]Restler 2: When calling index.php, display error 404
I am new to Restler 2.0 I trying to create an API, http://exampe.com/api/index.php/lbs/hello/123456 and it return success result But when i put http://exampe.com/api/index.php/lbs/getloc/123456 , it return fail. 我是Restler 2.0的新手,我试图创建一个API, http: //exampe.com/api/index.php/lbs/hello/123456,它返回成功结果,但是当我放http://exampe.com/api时/index.php/lbs/getloc/123456 ,返回失败。 Anyone know what does it happen?
有人知道会发生什么吗?
Result: 结果:
{
"error": {
"code": 404,
"message": "Not Found"
}
}
Below are the code: 下面是代码:
index.php index.php
require_once 'restler/restler.php';
require_once 'classes/lbs.php';
$r = new Restler();
$r->addAPIClass('LBS');
$r->addAPIClass('Say');
$r->handle();
lbs.php lbs.php
class LBS {
function getloc($to) {
return $to;
}
function hello($to) {
return $to;
}
}
You need to include the file containing the class Say
you added via addAPIClass
method. 您需要包含包含通过
addAPIClass
方法添加的“ Say
”类的文件。 Your index file should be something like below 您的索引文件应如下所示
require_once 'restler/restler.php';
require_once 'classes/lbs.php';
require_once 'classes/say.php';
$r = new Restler();
$r->addAPIClass('LBS');
$r->addAPIClass('Say');
$r->handle();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.