集成指南
详细的IPFixed集成步骤和最佳实践
环境配置
1. 设置环境变量
推荐使用环境变量来配置代理设置:
# Linux/macOS
export HTTP_PROXY=http://project-name:password@proxy.ipfixed.com:8080
export NO_PROXY=localhost,127.0.0.1
# Windows
set HTTP_PROXY=http://project-name:password@proxy.ipfixed.com:8080
2. 验证配置
使用curl命令测试代理连接:
curl -x http://project-name:password@proxy.ipfixed.com:8080 https://httpbin.org/ip编程语言集成
Node.js
const axios = require('axios');
const HttpsProxyAgent = require('https-proxy-agent');
const proxyUrl = 'http://project-name:password@proxy.ipfixed.com:8080';
const agent = new HttpsProxyAgent(proxyUrl);
axios.get('https://api.example.com/data', {httpsAgent: agent})
.then(response => console.log(response.data));Python
import requests
proxies = {
'http': 'http://project-name:password@proxy.ipfixed.com:8080',
'https': 'http://project-name:password@proxy.ipfixed.com:8080'
}
response = requests.get('https://api.example.com/data', proxies=proxies)
print(response.json())Java
System.setProperty("http.proxyHost", "proxy.ipfixed.com");
System.setProperty("http.proxyPort", "8080");
System.setProperty("http.proxyUser", "project-name");
System.setProperty("http.proxyPassword", "password");
System.setProperty("https.proxyHost", "proxy.ipfixed.com");
System.setProperty("https.proxyPort", "8080");
System.setProperty("https.proxyUser", "project-name");
System.setProperty("https.proxyPassword", "password");PHP
$context = stream_context_create([
'http' => [
'proxy' => 'tcp://proxy.ipfixed.com:8080',
'request_fulluri' => true,
'header' => "Proxy-Authorization: Basic " . base64_encode("project-name:password")
]
]);
$response = file_get_contents('https://api.example.com/data', false, $context);基础实践
环境变量配置
使用环境变量配置代理设置,避免在代码中硬编码敏感信息。
基础错误处理
实现基本的错误处理,包括代理连接失败和超时处理。
安全考虑
妥善保管项目凭据,定期更新密码,避免泄露敏感信息。
故障排除
连接超时
如果遇到连接超时,请检查:
- 代理地址和端口是否正确
- 用户名和密码是否正确
- 网络连接是否正常
认证失败
认证失败通常是由于:
- 项目名称或密码错误
- 项目已被删除
- 账户余额不足
IP被拒绝
如果目标API拒绝访问:
- 确认已将固定IP添加到目标服务的白名单
- 检查目标API的访问限制
- 联系技术支持获取帮助