短效代理
隧道代理
套餐购买
提取工具
帮助中心
产品手册
产品介绍
短效代理
隧道代理
常见问题
使用问题
购买问题
产品问题
开发者指南
开发者指南
快速入门
通用功能
API接口
白名单接口
错误码一览
短效代理接口
行业资讯
关于我们
登录
免费注册
控制台
{{ userInfo.sub_user?.name || userInfo.username }}
{{ userInfo.sub_user?.name || userInfo.username }}
个人认证
企业认证
未实名认证
¥
{{ userInfo.money }}
充值
会员中心
未支付订单
退出登录
首页
所有目录
{{ node.label }}
文档中心
>
隧道代理java语言接入指南
隧道代理java语言接入指南
发布时间:2026-08-12 10:07
``` package com.japroxy; import okhttp3.*; import java.io.IOException; import java.net.InetSocketAddress; import java.net.Proxy; import java.util.concurrent.TimeUnit; public class JAProxy { final static String proxyIp = "隧道地址"; final static Integer proxyPort = 隧道端口; final static String authKey = "AuthKey"; final static String password = "AuthPwd"; public Response request() throws IOException { Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyIp, proxyPort)); OkHttpClient client = new OkHttpClient.Builder() .proxy(proxy) .proxyAuthenticator((route, response) -> { String credential = Credentials.basic(authKey, password); return response.request().newBuilder().header("Proxy-Authorization", credential).build(); }) .build(); Request request = new Request.Builder().url("https://api.ipify.org").get().build(); return client.newCall(request).execute(); } public static void main(String[] args) { JAProxy jaProxy = new JAProxy(); try { Response resp = jaProxy.request(); System.out.println(resp.body().string()); } catch (Exception e) { System.out.printf("failed to proxy: %s\n", e.getMessage()); } } } ```
上一篇
隧道代理python语言接入指南
下一篇 没有了
大纲