Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t通过php curl对TMG进行身份验证_Php_Curl_Proxy_Authorization - Fatal编程技术网

Can';t通过php curl对TMG进行身份验证

Can';t通过php curl对TMG进行身份验证,php,curl,proxy,authorization,Php,Curl,Proxy,Authorization,我想在网络中用代理通过php中的curl打开网页。但不幸的是,TMG服务器无法验证我的身份并返回407错误。 这是我的代码: $ch = curl_init("http://google.com");; curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_PROXY, "http://192.168.4.10:8080"); curl_setopt($ch, CURLOPT_PROXYPORT,8080);

我想在网络中用代理通过php中的curl打开网页。但不幸的是,TMG服务器无法验证我的身份并返回407错误。 这是我的代码:

$ch = curl_init("http://google.com");;
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXY, "http://192.168.4.10:8080");
curl_setopt($ch, CURLOPT_PROXYPORT,8080);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "8909103:uvixqr");
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8');
//curl_setopt($ch, CURLOPT_HEADER, 1);
$x = curl_exec($ch);
var_dump($x);
curl_close($ch);
并返回以下错误:

Network Access Message: The page cannot be displayed Explanation: There is a problem with the page you are trying to reach and it cannot be displayed. Try the following: Refresh page: Search for the page again by clicking the Refresh button. The timeout may have occurred due to Internet congestion. Check spelling: Check that you typed the Web page address correctly. The address may have been mistyped. Access from a link: If there is a link to the page you are looking for, try accessing the page from that link. If you are still not able to view the requested page, try contacting your administrator or Helpdesk. Technical Information (for support personnel) Error Code: 407 Proxy Authentication Required. Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied. (12209) IP Address: 192.168.4.10 Date: 5/20/2012 6:51:36 AM [GMT] Server: ISA3.ee.kntu.local Source: proxy 网络访问消息:无法显示该页面 说明:您试图访问的页面有问题,无法显示。 请尝试以下操作: 刷新页面:单击刷新按钮再次搜索页面。超时可能是由于Internet拥塞造成的。 检查拼写:检查您键入的网页地址是否正确。地址可能输入错误。 从链接访问:如果有指向您正在查找的页面的链接,请尝试从该链接访问该页面。 如果您仍然无法查看请求的页面,请尝试与管理员或帮助热线联系。 技术信息(针对支持人员) 错误代码:需要407代理身份验证。Forefront TMG需要授权才能满足请求。对Web代理筛选器的访问被拒绝。(12209) IP地址:192.168.4.10 日期:2012年5月20日上午6:51:36[格林尼治标准时间] 服务器:ISA3.ee.kntu.local 资料来源:代理
问题在哪里?我应该如何解决它?

您正在设置代理端口两次:

curl_setopt($ch, CURLOPT_PROXY, "http://192.168.4.10:8080");
curl_setopt($ch, CURLOPT_PROXYPORT, 8080);
去掉CURLOPT_PROXY设置中的:8080,并将CURLOPT_PROXYPORT值加引号:

curl_setopt($ch, CURLOPT_PROXY, "http://192.168.4.10");
curl_setopt($ch, CURLOPT_PROXYPORT,"8080");
将其设置为详细模式也很有帮助:

curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl TMG(ISA3)身份验证:

url\u setopt($ch,CURLOPT\u PROXYAUTH,CURLAUTH\u NTLM)

curl_setopt($ch, CURLOPT_PROXY, "http://proxyserver:8080");
curl_setopt($ch, CURLOPT_PROXYPORT, 8080);
curl_setopt ($ch, CURLOPT_PROXYUSERPWD, "yourdomain.com\username:password");
它有效;)