Search...
Menu

How to use Rotating proxy through PHP?

Please note before configuration: PHP needs to be executed in non-mainland network environment for IPFoxy proxy to take effect


1. IPFoxy page operation

After purchasing a rotating proxy, go to the [Rotating Residential Proxy] page and complete the following operations:

1. Protocol type: http

2. Format: Username: Password@Host:Port

3. Generate Proxy

4. Copy the generated connection information

文章图片


2. Operation in PHP

1. Copy the following code into the PHP code, and paste the proxy connection information just copied from IPFoxy into the code, such as the proxy connection information is: username:password@gate-us-ipfoxy.io:58688

function get_file_curl($url,$proxy_host,$proxy_port,$loginpassw)
    {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_PROXYPORT, $proxy_port);
     curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
     curl_setopt($ch, CURLOPT_PROXY, $proxy_host);
     curl_setopt($ch, CURLOPT_PROXYUSERPWD, $loginpassw);
     curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); 
     $data = curl_exec($ch);
     curl_close($ch);
     return $data;
    }
    var_dump(get_file_curl("https://lumtest.com/myip.json", "http://gate-us-ipfoxy.io", "58688", "username:password"));



Share this Article
Previous
How to use Rotating proxy through Java?
Next
How to use Rotating proxy through GO?
Last modified: 2024-11-18Powered by