-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
25 lines (19 loc) · 774 Bytes
/
Copy pathexample.php
File metadata and controls
25 lines (19 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
// Guzzle behind an authenticated residential proxy.
// composer require guzzlehttp/guzzle
// QP_USER=... QP_PASS=... php example.php
require __DIR__ . '/vendor/autoload.php';
use GuzzleHttp\Client;
$user = (getenv('QP_USER') ?: 'YOUR_USERNAME');
$pass = (getenv('QP_PASS') ?: 'YOUR_PASSWORD');
$rotating = sprintf(
'http://%s-country-us:%s@residentialboson.quantumproxies.io:9000',
$user,
$pass
);
$client = new Client(['proxy' => $rotating, 'timeout' => 30]);
// two calls through the rotating port -> two different exit IPs
foreach ([1, 2] as $i) {
$info = json_decode((string) $client->get('https://ipinfo.io/json')->getBody(), true);
printf("request %d: %s (%s, %s)\n", $i, $info['ip'], $info['country'] ?? '?', $info['city'] ?? '?');
}