gMod
gMod

Reputation: 9

How to make a PHP program work via proxies?

I have never delt with proxies but now I have to. The program is a PHP parser that scraps several websites to retrieve need info. I just need to know how PHP programs work via proxies... how to make them work via proxies.

Thanks for any help!

Upvotes: 0

Views: 367

Answers (2)

Bergi
Bergi

Reputation: 76

http://php.net/stream_context_create

For example:

<?php
    $opts = array ( 'http' => array ( 'proxy' => 'tcp://proxy:8080', 'request_fulluri' => true ) ) ;
    $context = stream_context_create ( $opts ) ;
    $f = file_get_contents ( 'http://yoururl/', false, $context ) ;

Upvotes: 1

Shubham
Shubham

Reputation: 22307

You can use curl with CURLOPT_PROXY Option.

http://www.php.net/manual/en/function.curl-setopt.php

Upvotes: 2

Related Questions