my college internet requires us to set proxyHost to " 172.16.1.3 " and proxy port to " 3128 " and then when we restart the browser i will be asked to enter a user name and password to connect to the internet ..user name is "2006it088" and pass is "shivram" .

my project requires me to give the input as a web page and then after a few operations display it ..because of the proxy settingsin my college i am not able to display the output ..

my friend gave me a java code that does the proxy settings and enters username & pass automatically ..it works for his project which is in JAVA

//Properties systemSettings = System.getProperties();
//systemSettings.put("proxySet", "true");
// systemSettings.put("http.proxyHost", "172.16.1.3");
// systemSettings.put("http.proxyPort", "3128");
//sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder();
// String encodedUserPwd = encoder.encode("2006it088:shivram".getBytes());
// con.setRequestProperty("Proxy-Authorization", "Basic " + encodedUserPwd);
//con.setRequestMethod("HEAD");

i need a php code to do the proxy settings automatically and then enter the username and password automatically so that the output can be displayed
..please help

    Just to make sure we're clear... you're trying to accept a URL as input and want your PHP script to download the contents of the remote website, but must use an internal proxy in order to get to the internet?

    If so, I would recommend you look into using [man]cURL[/man]. If you'll look on the manual page for [man]curl_setopt/man, there are two options of interest to you - CURLOPT_PROXY, and CURLOPT_PROXYUSERPWD (and possibly CURLOPT_HTTPPROXYTUNNEL).

      yes mate ..you are exactly right
      i tried this

      $ch=curl_init();
      curl_setopt($ch,CURLOPT_PROXY,'172.16.1.3:3128');
      curl_setopt($ch,CURLOPT_PROXYUSERPWD,'abc:123');

      is this right ??

      should i include this too

      curl_setopt($ch, CURLOPT_URL, 'http://example.com/page1.php');
      $result1 = curl_exec($ch);
      or is this not needed

        Write a Reply...