开发者

Bare bones PHP proxy

开发者 https://www.devze.com 2023-03-08 20:40 出处:网络
I\'m not开发者_Go百科 a PHP guy, but I need to set up a bare bones proxy for a web service.As an example, let\'s use google.Let\'s say that I have a proxy server set up at: http://mydumbproxy.com/inde

I'm not开发者_Go百科 a PHP guy, but I need to set up a bare bones proxy for a web service. As an example, let's use google. Let's say that I have a proxy server set up at: http://mydumbproxy.com/index.php and I want it to act just like http://www.google.com/search. So for instance, if someone typed in the url http://mydumbproxy.com/index.php?q=dancing+banana, they would get the same thing as if they had typed in http://www.google.com/search?q=dancing+banana

How would I do this?

Note: Eventually this will become more than a straight passthrough. It will provide a security layer between the public at large and dangerous access of the base web service.


This is probably a move in the right direction:

fpassthru(fopen('http://www.google.com/search?' . $_SERVER['QUERY_STRING'], 'r'));


After starting with Franks answer and googling a bit and put this scrap together which seems to do what I want:

<?php
echo file_get_contents('http://www.example.com/search?' . $_SERVER['QUERY_STRING'], 'r');
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消