• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 577
  • Last Modified:

How to use proxy with PHP?

Hi,

I want to develop a php program to get information from the website and store them in the local database. The difficulties here is that I am in the internal web, and the machine host my program can only access the internet by proxy. So how can I use php programming to access the internet through the proxy server?

Thank you.
0
mryyzx
Asked:
mryyzx
2 Solutions
 
hernst42Commented:
That will only work with the curl-module. Via the normal PHP-function like fopen fget_content, ..there is no support for proxy. For curl see http://de3.php.net/manual/en/ref.curl.php
0
 
andYetAnotherLoginNameCommented:
on the contrary, you can do whatever you'd like. use fsockopen to negotiate your proxy.

you'll basically need something like this:
$fp = fsockopen ("proxe.server.here", 80, $errno, $errstr, 30);
if (!$fp) {
    echo "$errstr ($errno)<br>\n";
} else {
    fputs ($fp, "GET http://needed.server.here/file.ext HTTP/1.0\r\n\r\n");
    while (!feof($fp)) {
        echo fgets ($fp,128);
    }
    fclose ($fp);
}
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now