danielrvt
danielrvt

Reputation: 10926

Get requested service in Restler iAuthenticate implementation

I'm using Restler to develop a REST api and I need to get the requested service from the iAuthenticate implementation.

So far I have managed to get here:

$m = preg_match('/.+?\/(?P<api>.+?)\/(?P<service>\w+)/', $_SERVER['REQUEST_URI']);

and $_SERVER['REQUEST_URI'] has this form: /somedir/apiclass/requestedservice?...

I've tried my regex here: http://www.spaweditor.com/scripts/regex/index.php with my actual uri and it works perfectly. When I try to parse the request url inside my iAuthenticate implementation it just don't work.

Does anybody know how to enable regex within restler iAuthenticate implementation? How can I display errors in Restler instead of a blank page?

Thanks!

[EDIT]

I wasn't passing the variable to store the match object, preg_match recieves a third argument to store it and just returns a boolean. Case closed.

Upvotes: 1

Views: 218

Answers (1)

danielrvt
danielrvt

Reputation: 10926

I finally solved it like this:

preg_match('/.+?\/(?P<api>.+?)\/(?P<service>\w+)/', $_SERVER['REQUEST_URI'], $mo);

$api = $mo['api'];
$service = $mo['service'];

Upvotes: 1

Related Questions