我有以下代码,但它总是返回一个407 HTTP状态代码.
$url = 'http://whatismyip.org'; $client = new Client(); $options = array( 'proxy' => array( 'http' => 'tcp://@x.x.x.x:8010',),'auth' => array('d80fe9ebasab73d21a4','','basic') ); $crawler = $client->request('GET',$url,$options); $status = $client->getResponse()->getStatus(); echo $status; // 407
我使用Gozzte with Guzzle 6.我开始尝试使用setDefaultOption设置代理,但是这种方法已被弃用.
我的用户名和空白密码绝对正确,因为它与命令行上的curl一起使用:
curl -U d80fe9ebasab73d21a4: -vx x.x.x.x:8010 http://whatismyip.org/
我已经花了几个小时这个,我会感谢任何帮助!
您是否尝试使用代理选项直接实例化您的客户端?
原文链接:https://www.f2er.com/php/131370.html喜欢这个:
$url = 'http://whatismyip.org'; $client = new Client($url,array( 'version' => 'v1.1','request.options' => array( 'auth' => array('d80fe9ebasab73d21a4','Basic'),'proxy' => 'tcp://@x.x.x.x:8010' ) )); $crawler = $client->request('GET',$url); $status = $client->getResponse()->getStatus(); echo $status; // 407