PHP curl 请求中设置 proxy 方法



$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://www.google.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 信任任何证书

curl_setopt($ch, CURLOPT_PROXY, "127.0.0.1");
curl_setopt($ch, CURLOPT_PROXYPORT, "10809");
// curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);  // CURLPROXY_SOCKS5
// curl_setopt($ch, CURLOPT_PROXYUSERPWD, "username:password");

$output = curl_exec($ch);
var_export($output);
var_export(curl_error($ch));

curl_close($ch);

  • 参考
    https://blog.csdn.net/mypowerhere/article/details/97260758 PHP 使用 CURL 配置代理
    https://blog.csdn.net/qq_38191191/article/details/82771869 php curl 实现发送 get和 post 请求
    https://blog.csdn.net/u012382791/article/details/51408523 PHP 笔记:后台get和post带参请求的封装
    https://www.libaocai.com/6958.html php SSL certificate problem: unable to get local issuer certificate 解决办法
    https://www.it1352.com/2024852.html 在 Guzzle 中设置代理(Set proxy in Guzzle)

你可能感兴趣的:(开发,php,http,curl,proxy,guzzle)