I wanna open web page via curl in php in network with proxy.But unfortunately TMG server can’t authenticate me and return 407 error.
this is my code:
$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);
and following error returned:
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
where is the problem and how should I solve it?
curl TMG (ISA3) authentication :
url_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
it works 😉