PHP cURL extension for HTTP requests through KnoxProxy. Two cURL options and your scraper is proxied.
Use CURLOPT_PROXY.
$ch = curl_init("https://httpbin.org/ip");
curl_setopt($ch, CURLOPT_PROXY, "http://gw.knoxproxy.com:7000");
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "USER:PASS");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);Run the request.
$response = curl_exec($ch);
curl_close($ch);
echo $response;Add country to username.
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "USER-country-de:PASS");Use SOCKS5 proxy type.
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($ch, CURLOPT_PROXY, "gw.knoxproxy.com:7001");Check for errors.
if (curl_errno($ch)) {
echo "Error: " . curl_error($ch);
}Verify exit IP.
echo $response;<?php
/**
* KnoxProxy + PHP cURL -- complete working example.
*/
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => "https://httpbin.org/ip",
CURLOPT_PROXY => "http://gw.knoxproxy.com:7000",
CURLOPT_PROXYUSERPWD => "USER:PASS",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => true,
]);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo "Error: " . curl_error($ch) . "\n";
} else {
echo "Exit IP: " . $response . "\n";
}
curl_close($ch);
// Country-targeted request
$ch = curl_init("https://httpbin.org/ip");
curl_setopt($ch, CURLOPT_PROXY, "http://gw.knoxproxy.com:7000");
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "USER-country-us:PASS");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
echo "US IP: " . $response;
curl_close($ch);Each curl_exec() gets a new IP. For sticky sessions, add -session-{id} to the username.
| Problem | Fix |
|---|---|
| CURLE_COULDNT_CONNECT | Verify host, port, and firewall. |
| HTTP 407 | Check CURLOPT_PROXYUSERPWD format: USER:PASS. |
USER-country-de-city-berlin-session-profile07Order matters -- geo flags before the session flag. The session name is free text; use the profile ID so the mapping is self-documenting. Password stays as issued; no flags belong there. HTTP on :7000, SOCKS5 on :7001, same credentials.
Yes. Guzzle uses cURL under the hood. Pass [proxy => "http://USER:PASS@gw.knoxproxy.com:7000"] in request options.
Use curl_multi for concurrent proxied requests. Each handle in the multi stack gets its own KnoxProxy IP.
Yes. Laravel HTTP client wraps Guzzle. Use Http::withOptions([proxy => PROXY_URL])->get(url).
Keep CURLOPT_SSL_VERIFYPEER = true. Update your CA bundle if you get certificate errors.
Free trial on rotating residential -- 2 minutes setup, no credit card.