Skip to main content
Replace credentials with your Dashboard values.

cURL

<?php

$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.ipify.org',
    CURLOPT_PROXY => 'http://p1.turnoxy.com:1318',
    CURLOPT_PROXYUSERPWD => 'sub_xxx:pass',
    CURLOPT_RETURNTRANSFER => true,
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;

With Parameters

<?php

$ch = curl_init();

// Target US IPs
curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.ipify.org',
    CURLOPT_PROXY => 'http://p1.turnoxy.com:1318',
    CURLOPT_PROXYUSERPWD => 'sub_xxx-country-US:pass',
    CURLOPT_RETURNTRANSFER => true,
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;

Sticky Session

<?php

// Same IP for multiple requests
$proxy = 'http://p1.turnoxy.com:1318';
$auth = 'sub_xxx-session-order123-ttl-10:pass';

for ($i = 1; $i <= 3; $i++) {
    $ch = curl_init();
    curl_setopt_array($ch, [
        CURLOPT_URL => 'https://api.ipify.org',
        CURLOPT_PROXY => $proxy,
        CURLOPT_PROXYUSERPWD => $auth,
        CURLOPT_RETURNTRANSFER => true,
    ]);
    $response = curl_exec($ch);
    curl_close($ch);
    echo "Request $i: $response\n";
}

Guzzle

<?php

require 'vendor/autoload.php';

use GuzzleHttp\Client;

$client = new Client([
    'proxy' => 'http://sub_xxx:[email protected]:1318'
]);

$response = $client->get('https://api.ipify.org');
echo $response->getBody();

With Parameters

<?php

require 'vendor/autoload.php';

use GuzzleHttp\Client;

// Target Germany IPs
$client = new Client([
    'proxy' => 'http://sub_xxx-country-DE:[email protected]:1318'
]);

$response = $client->get('https://api.ipify.org');
echo $response->getBody();

Concurrent Requests

<?php

require 'vendor/autoload.php';

use GuzzleHttp\Client;
use GuzzleHttp\Promise\Utils;

$client = new Client([
    'proxy' => 'http://sub_xxx:[email protected]:1318'
]);

$promises = [];
for ($i = 0; $i < 5; $i++) {
    $promises[] = $client->getAsync('https://api.ipify.org');
}

$results = Utils::unwrap($promises);

foreach ($results as $i => $response) {
    echo "Request " . ($i + 1) . ": " . $response->getBody() . "\n";
}

file_get_contents

<?php

$context = stream_context_create([
    'http' => [
        'proxy' => 'tcp://p1.turnoxy.com:1318',
        'request_fulluri' => true,
        'header' => 'Proxy-Authorization: Basic ' . base64_encode('sub_xxx:pass')
    ]
]);

$response = file_get_contents('http://api.ipify.org', false, $context);
echo $response;
file_get_contents with proxy only works for HTTP targets, not HTTPS. Use cURL or Guzzle for HTTPS.