Question

I'm using Fat Free Framework and I want to handle an incoming request like: http://example.com/api/method/?user_id=1&url=http://newsite.com

I use the F3::route method to handle GET requests to this method but I get the following error:

parse_url(/method?user_id=1&url=http://newsite.com): Unable to parse URL

I think I've tracked this down to a problem with the PHP function parse_url() which fails on relative URLs.

Any ideas how I can get F3 to properly handle URLs in the GET query params?

Was it helpful?

Solution

I've run into this problem before. If you don't have control of the incoming URL not being url-encoded, you can do this as a dirty hack before F3 is run to get rid of the slashes in the argument:

$_SERVER['REQUEST_URI'] = str_replace('http://', 'http:', $_SERVER['REQUEST_URI']);

OTHER TIPS

why not simplify and use urlencode('http://www.google.com');???

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top