ProxioDocs
Integrations

Other Languages

Route PHP, Java, C#, and Go through Proxio over HTTP or SOCKS5, the same four languages the dashboard's code generator covers, as complete minimal programs.

The dashboard's own code generator produces ready-to-paste examples in cURL, PHP, Python, Node.js, Java, C#, and Go. Python and Node.js each get their own guide; this page covers the rest: PHP, Java, C#, and Go.

PHP

PHP's curl extension is bundled with almost every install and needs no extra package.

<?php

$username = 'USERNAME';
$password = 'PASSWORD';

$ch = curl_init('https://ipinfo.io/json');
curl_setopt($ch, CURLOPT_PROXY, 'geo.proxio.cc:16666');
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

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

echo $response;
<?php

$username = 'USERNAME';
$password = 'PASSWORD';

$ch = curl_init('https://ipinfo.io/json');
curl_setopt($ch, CURLOPT_PROXY, 'geo.proxio.cc:16666');
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

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

echo $response;

Resolving DNS through the proxy

PHP's curl extension also defines CURLPROXY_SOCKS5_HOSTNAME, which resolves the destination hostname on the proxy side instead of locally (the same idea as socks5h:// in other languages). Swap it in if a target hostname doesn't resolve locally.

Verify: run php script.php. It prints the JSON body from ipinfo.io with the proxy's exit IP.

Java

Two ways to route Java through Proxio: plain java.net with system properties (no dependency beyond the JDK), or OkHttp if your project already uses it.

Plain java.net

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.Authenticator;
import java.net.HttpURLConnection;
import java.net.PasswordAuthentication;
import java.net.URL;

public class ProxioHttp {
    public static void main(String[] args) throws Exception {
        System.setProperty("http.proxyHost", "geo.proxio.cc");
        System.setProperty("http.proxyPort", "16666");
        System.setProperty("https.proxyHost", "geo.proxio.cc");
        System.setProperty("https.proxyPort", "16666");

        Authenticator.setDefault(new Authenticator() {
            @Override
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication("USERNAME", "PASSWORD".toCharArray());
            }
        });

        HttpURLConnection conn = (HttpURLConnection) new URL("https://ipinfo.io/json").openConnection();
        BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        StringBuilder body = new StringBuilder();
        String line;
        while ((line = reader.readLine()) != null) {
            body.append(line);
        }
        reader.close();
        System.out.println(body);
    }
}
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class ProxioSocks {
    public static void main(String[] args) throws Exception {
        System.setProperty("socksProxyHost", "geo.proxio.cc");
        System.setProperty("socksProxyPort", "16666");
        System.setProperty("java.net.socks.username", "USERNAME");
        System.setProperty("java.net.socks.password", "PASSWORD");

        HttpURLConnection conn = (HttpURLConnection) new URL("https://ipinfo.io/json").openConnection();
        BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        StringBuilder body = new StringBuilder();
        String line;
        while ((line = reader.readLine()) != null) {
            body.append(line);
        }
        reader.close();
        System.out.println(body);
    }
}

Once socksProxyHost is set, every plain java.net.Socket, including the one behind HttpURLConnection, tunnels through SOCKS5 automatically, so the request code above doesn't change at all.

OkHttp

import java.net.InetSocketAddress;
import java.net.Proxy;
import okhttp3.Credentials;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class ProxioOkHttp {
    public static void main(String[] args) throws Exception {
        Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("geo.proxio.cc", 16666));

        OkHttpClient client = new OkHttpClient.Builder()
            .proxy(proxy)
            .proxyAuthenticator((route, response) -> response.request().newBuilder()
                .header("Proxy-Authorization", Credentials.basic("USERNAME", "PASSWORD"))
                .build())
            .build();

        Request request = new Request.Builder().url("https://ipinfo.io/json").build();
        try (Response response = client.newCall(request).execute()) {
            System.out.println(response.body().string());
        }
    }
}

For SOCKS5 with OkHttp, use new Proxy(Proxy.Type.SOCKS, ...) and drop proxyAuthenticator. OkHttp defers the SOCKS5 handshake to the JVM, so credentials come from the java.net.socks.username/java.net.socks.password properties shown above instead.

Verify: run either class. The printed body is the JSON from ipinfo.io, with the proxy's exit IP.

C#

using System;
using System.Net;
using System.Net.Http;

var handler = new HttpClientHandler
{
    Proxy = new WebProxy("http://geo.proxio.cc:16666")
    {
        Credentials = new NetworkCredential("USERNAME", "PASSWORD"),
    },
    UseProxy = true,
};

using var client = new HttpClient(handler);
var body = await client.GetStringAsync("https://ipinfo.io/json");
Console.WriteLine(body);
using System;
using System.Net;
using System.Net.Http;

var handler = new HttpClientHandler
{
    Proxy = new WebProxy("socks5://geo.proxio.cc:16666")
    {
        Credentials = new NetworkCredential("USERNAME", "PASSWORD"),
    },
    UseProxy = true,
};

using var client = new HttpClient(handler);
var body = await client.GetStringAsync("https://ipinfo.io/json");
Console.WriteLine(body);

.NET 6 or later

SOCKS5 support was added to SocketsHttpHandler in .NET 6. .NET always resolves the destination hostname locally before handing the connection to the proxy (there's no socks5h equivalent), so socks5:// is correct as written above.

Verify: dotnet run prints the JSON body with the proxy's exit IP.

Go

package main

import (
	"fmt"
	"io"
	"net/http"
	"net/url"
)

func main() {
	proxyURL, err := url.Parse("http://USERNAME:[email protected]:16666")
	if err != nil {
		panic(err)
	}

	client := &http.Client{
		Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)},
	}

	resp, err := client.Get("https://ipinfo.io/json")
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
package main

import (
	"context"
	"fmt"
	"io"
	"net"
	"net/http"

	"golang.org/x/net/proxy"
)

func main() {
	auth := &proxy.Auth{User: "USERNAME", Password: "PASSWORD"}

	dialer, err := proxy.SOCKS5("tcp", "geo.proxio.cc:16666", auth, proxy.Direct)
	if err != nil {
		panic(err)
	}

	transport := &http.Transport{
		DialContext: func(_ context.Context, network, addr string) (net.Conn, error) {
			return dialer.Dial(network, addr)
		},
	}

	client := &http.Client{Transport: transport}

	resp, err := client.Get("https://ipinfo.io/json")
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}

SOCKS5 needs one extra module: go get golang.org/x/net/proxy. The HTTP tab uses only the standard library.

Verify: go run main.go prints the JSON body with the proxy's exit IP.

On this page