title: php - CURL HTTP Authentication at server side
body: <p>i want to change xml value in php  but don't change ....</p>
  
  <pre><code>&lt;?php
  
  $url = "http://192.168.1.103:8080/ew.xml";
  $xml = '&lt;?xml version="1.0" ?&gt;
  &lt;DDCConfig:getValue xmlns:DDCConfig="urn:SMUDDCConfiguration"&gt;
  &lt;DDCConfig:Network&gt;
   &lt;DDCConfig:LocalIP&gt;192.168.103.223&lt;/DDCConfig:LocalIP&gt;
   &lt;DDCConfig:GlobalIP&gt;168.188.127.123&lt;/DDCConfig:GlobalIP&gt;
  &lt;DDCConfig:RootBridge&gt;Yes&lt;/DDCConfig:RootBridge&gt;
  &lt;/DDCConfig:Network&gt;
  &lt;/DDCConfig:getValue&gt;';
  
  $ch = curl_init(); 
  curl_setopt($ch, CURLOPT_VERBOSE, 1);
  curl_setopt($ch, CURLOPT_USERPWD, "lmk:alrud89");
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($ch, CURLOPT_URL, "$url"); 
  curl_setopt($ch, CURLOPT_PORT, 8080);
  curl_setopt($ch, CURLOPT_PUT, 1); 
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
  curl_setopt($ch, CURLOPT_POSTFIELDS,array($xml));
  $http_result = curl_exec($ch);
  if($http_result){
  echo $http_result;
  }else{
  echo curl_error($ch);
  }
  
  curl_close($ch); 
  ?&gt;
  </code></pre>
  
  <p>error message is</p>
  
  <blockquote>
    <p>* About to connect() to 192.168.1.103 port 8080 (#0) 
    * Trying 192.168.1.103...<br>
    * connected<br>
    * Server auth using Basic with user 'lmk'<br>
    > PUT /ew.xml HTTP/1.1<br>
    > Authorization: Basic bG1rOmFscnVkODk=<br>
    > Host: 192.168.1.103:8080 Accept: <em>/</em><br>
    > Transfer-Encoding: chunked<br>
    > Expect: 100-continue<br>
    &lt; HTTP/1.1 401 Unauthorized<br>
    &lt; Content-Length: 0<br>
    &lt;<br>
    > WWW-Authenticate: Digest qop="auth", realm="mydomain.com",
    nonce="1366254379"<br>
    * HTTP error before end of send, stop sending<br>
    * Closing connection #0</p>
  </blockquote>
  
  <p>what is the problem &amp; solution?</p>