Question

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. Anyone know what does it happen?

Result:

{
  "error": {
    "code": 404,
    "message": "Not Found"
  }
}

Below are the code:

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

class LBS {
    function getloc($to) {
        return $to;
    }

    function hello($to) {
        return $to;
        }
}
Was it helpful?

Solution

You need to include the file containing the class Say you added via addAPIClass method. 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();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top