簡體   English   中英

無法通過php curl驗證TMG

[英]Can't Authenticate TMG via php curl

我想通過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

問題在哪里,我該如何解決?

curl TMG(ISA3)身份驗證:

url_setopt($ ch,CURLOPT_PROXYAUTH,CURLAUTH_NTLM);

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

有用 ;)

您正在設置代理端口兩次:

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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM