문제

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?

도움이 되었습니까?

해결책

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']);

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top