Integration

Shifter verwenden mit PHP

Binden Sie Shifters Wohn- und ISP-Proxys in jedes PHP-Projekt ein -- cURL, Guzzle, Symfony HttpClient, Laravel oder WordPress -- ohne eine einzige Zeile Ihrer Geschäftslogik zu ändern.

Schnellstart

Installieren

composer require guzzlehttp/guzzle

Grundlegende Nutzung

<?php
require 'vendor/autoload.php';

use GuzzleHttp\Client;

$client = new Client([
    'proxy' => 'customer-USERNAME-country-us-sid-123ABC:PASSWORD@p.shifter.io:443',
    'timeout' => 30,
]);

$response = $client->get('https://ipinfo.io/json');
$data = json_decode($response->getBody(), true);

print_r($data);
// ["ip" => "154.16.xxx.xxx", "city" => "New York", "country" => "US", ...]

Funktionen

Funktioniert sofort mit cURL, Guzzle, Symfony HttpClient, Laravel Http und WordPress wp_remote_get
Standardmäßig Rotation pro Anfrage, mit `sid` für Sticky Sessions und `ttl-N` für zeitgesteuerte Pins von N Sekunden
Kompatibel mit PHP 7.4 und jeder PHP 8.x-Version einschließlich 8.3
HTTP, HTTPS und SOCKS5 Protokolle am selben Gateway-Endpunkt
Geo-Targeting in 195+ Ländern über Username-Parameter - kein zusätzliches Paket erforderlich
Drop-in für Laravel, Symfony, WordPress und jedes benutzerdefinierte PHP-Framework -- keine SDK-Bindung

Beispiele

Einfaches cURL

Keine Abhängigkeiten -- nur die Standard-PHP-cURL-Erweiterung. Verwenden Sie dies, wenn Sie keine Composer-Pakete installieren können oder möchten.

<?php
$proxyUser = 'customer-USERNAME-country-us-sid-123ABC';
$proxyPass = 'PASSWORD';
$proxyHost = 'p.shifter.io:443';

$ch = curl_init();
curl_setopt_array($ch, [
    CURLOPT_URL            => 'https://example.com',
    CURLOPT_PROXY          => $proxyHost,
    CURLOPT_PROXYUSERPWD   => "$proxyUser:$proxyPass",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT        => 30,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTPHEADER     => [
        'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
    ],
]);

$body   = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo "Status: $status, Length: " . strlen($body) . "\n";

Guzzle mit Sticky Session

Verwenden Sie dieselbe Wohn-IP in einem mehrstufigen Workflow wieder, indem Sie dem Benutzernamen eine `sid` hinzufügen. Fügen Sie `country-de`, `city-berlin` oder `asn-7922` für Geo-Targeting hinzu.

<?php
require 'vendor/autoload.php';

use GuzzleHttp\Client;

$sid = bin2hex(random_bytes(4));

$client = new Client([
    'proxy'    => "customer-USERNAME-country-de-city-berlin-sid-$sid-ttl-300:PASSWORD@p.shifter.io:443",
    'timeout'  => 30,
    'headers'  => [
        'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36',
    ],
]);

$login     = $client->post('https://example.de/login', [
    'form_params' => ['email' => 'user@example.com', 'password' => 'secret'],
]);
$dashboard = $client->get('https://example.de/dashboard');
$orders    = $client->get('https://example.de/orders');

echo $login->getStatusCode(), ' ', $dashboard->getStatusCode(), ' ', $orders->getStatusCode();

Symfony HttpClient

Die HttpClient-Komponente von Symfony unterstützt HTTP / 2 und ist in Symfony 6+ und 7 enthalten. Konfigurieren Sie den Proxy global oder pro Anfrage.

<?php
use Symfony\Component\HttpClient\HttpClient;

$client = HttpClient::create([
    'proxy'   => 'customer-USERNAME-country-fr-sid-456DEF:PASSWORD@p.shifter.io:443',
    'timeout' => 30,
    'headers' => [
        'User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36',
    ],
]);

$response = $client->request('GET', 'https://api.example.fr/products');

if ($response->getStatusCode() === 200) {
    $products = $response->toArray();
    foreach ($products as $product) {
        echo "{$product['name']}: {$product['price']} EUR\n";
    }
}

Laravel HTTP Client

Laravels Http-Fassade umhüllt Guzzle. Konfigurieren Sie den Proxy in einem Service Provider, damit jeder Http-Aufruf Ihrer Anwendung über Shifter geleitet wird.

<?php
namespace App\Providers;

use Illuminate\Support\Facades\Http;
use Illuminate\Support\ServiceProvider;

class HttpServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        Http::macro('shifter', function (string $sid = '') {
            $sidPart = $sid ? "-sid-$sid" : '';
            $proxy   = "customer-USERNAME-country-uk$sidPart:PASSWORD@p.shifter.io:443";

            return Http::withOptions([
                'proxy'           => $proxy,
                'timeout'         => 30,
                'connect_timeout' => 10,
            ]);
        });
    }
}

// Anywhere in your app:
$response = Http::shifter('789GHI')->get('https://example.co.uk/products');
$products = $response->json();
FAQ

Häufig gefragt FAQ-Fragen

Häufige Fragen zur Verwendung von Shifter mit PHP.

Verwenden Sie curl_setopt mit CURLOPT_PROXY auf `p.shifter.io:443` und CURLOPT_PROXYUSERPWD auf `customer-USERNAME-country-us-sid-123ABC:PASSWORD`. Keine zusätzlichen Bibliotheken erforderlich -- die Standard-PHP-cURL-Erweiterung reicht aus.

Jetzt starten

Shifter verwenden mit PHP

Binden Sie Shifters 205M+ Residential- und ISP-Proxys in weniger als 5 Minuten in Ihren PHP-Stack ein. Funktioniert mit Laravel, Symfony, WordPress und reinem cURL.

Shifter kostenlos testenIn Minuten eingerichtet. Jederzeit kuendbar.