0

I am using Restler 2.1.5 and i have a class with the index method protected.

protected function index($id){
//do something
}

I added new protected method but not able to call that method.

protected function method(){
//do stuff
}

When i call http://localhost/api/index.php/class?key=foo it runs all OK

But when i call http://localhost/api/index.php/method?key=foo it gives me not found

What can be causing this?

Filipe Batista
  • 1,862
  • 2
  • 24
  • 39

1 Answers1

1

It is because you are looking at the wrong place!

try the following url instead

http://localhost/api/index.php/class/method?key=foo

If you do not pass '' (blank String) as the second parameter to $r->addAPIClass() name of the class will be included in the route and thus you need to include it in your url too

You should also understand the ambiguity and order of priority, reading this thread will help you

Arul Kumaran
  • 983
  • 7
  • 23
  • Still not working. In the examples, in the _005_protected_api in the class `Simple` if you add: `protected function index($a){ return "hello".$a; }` and then if you call http://localhost/examples/_005_protected_api/index.php/simple/restricted?key=rEsTlEr2 It will return the `hellorestricted`, in other words, it is calling the index method Since the `index` as a parameter it will always call the index method, even if i indicated the method name. Am i right? – Filipe Batista Jun 04 '12 at 11:25
  • that is order of priority issue. I have updated my answer with the link to the solution – Arul Kumaran Jun 04 '12 at 22:52