1. Go to this page and download the library: Download tregor/proxyman library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tregor / proxyman example snippets
use tregor\ProxyMan\Exception\ProxyException;
use tregor\ProxyMan\ProxyManager;
//Adding proxy to manager
ProxyManager::addProxyHTTP("127.0.0.1", "3128");
//Simple Curl request with proxy
$ch = curl_init("https://www.google.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
try{
//Getting random proxy from Manager
$proxy = ProxyManager::getRandomProxy();
}catch (ProxyException $e){
echo "Error occurred: ".$e->getMessage();
}
//Setting Curl proxy type by Proxy method
curl_setopt($ch, CURLOPT_PROXYTYPE, $proxy->getType());
//Setting Curl proxy host and port string by Proxy method
curl_setopt($ch, CURLOPT_PROXY, $proxy->getHostPort());
if ($proxy->hasAuth()){
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
//Setting Curl proxy username and password string by Proxy method
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy->getUserPass());
}
$response = curl_exec($ch);
curl_close($ch);
echo "<pre>".$response."</pre>";