-
-
Save pnlinh07/3d5f4199f95440056b32d2165e0c2474 to your computer and use it in GitHub Desktop.
Get contents through proxy using curl or guzzle - tested wit bestproxyandvpn.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PROXY_USER=... | |
| PROXY_PASS=.... | |
| PROXY_IP=185.XXX.XXX.XXX | |
| PROXY_PORT=37257 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "24hoursmedia/proxy-test", | |
| "require": { | |
| "vlucas/phpdotenv": "^2.5", | |
| "guzzlehttp/guzzle": "^6.3" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Request through a Best VPN proxy using curl | |
| */ | |
| require __DIR__ . '/../vendor/autoload.php'; | |
| $dotenv = new Dotenv\Dotenv(__DIR__ . '/../'); | |
| $dotenv->load(); | |
| $PROXY_IP = getenv('PROXY_IP'); | |
| $PROXY_PORT = getenv('PROXY_PORT'); | |
| $PROXY_USER = getenv('PROXY_USER'); | |
| $PROXY_PASS = getenv('PROXY_PASS'); | |
| $url = 'https://manytools.org/http-html-text/http-request-headers/'; | |
| $ch = curl_init($url); | |
| curl_setopt($ch, CURLOPT_PROXY, $PROXY_IP); | |
| curl_setopt($ch, CURLOPT_PROXYPORT, $PROXY_PORT); | |
| curl_setopt($ch, CURLOPT_PROXYUSERNAME, $PROXY_USER); | |
| curl_setopt($ch, CURLOPT_PROXYPASSWORD, $PROXY_PASS); | |
| $result = curl_exec($ch); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Request through a Best VPN proxy using guzzle | |
| */ | |
| require __DIR__ . '/../vendor/autoload.php'; | |
| use GuzzleHttp\Client; | |
| $dotenv = new Dotenv\Dotenv(__DIR__ . '/../'); | |
| $dotenv->load(); | |
| $PROXY_IP = getenv('PROXY_IP'); | |
| $PROXY_PORT = getenv('PROXY_PORT'); | |
| $PROXY_USER = getenv('PROXY_USER'); | |
| $PROXY_PASS = getenv('PROXY_PASS'); | |
| $url = 'https://manytools.org/http-html-text/http-request-headers/'; | |
| $proxyClient = new Client([ | |
| 'proxy' => rawurlencode($PROXY_USER) . ':' . rawurlencode($PROXY_PASS) . '@' . $PROXY_IP . ':' . $PROXY_PORT, | |
| 'headers' => [ | |
| 'User-Agent' => 'my simulated user agent' | |
| ] | |
| ]); | |
| $result = $proxyClient->get($url)->getBody()->getContents(); | |
| echo $result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment