xml - php - CURL HTTP Authentication at server side -
i want change xml value in php don't change ....
<?php $url = "http://192.168.1.103:8080/ew.xml"; $xml = '<?xml version="1.0" ?> <ddcconfig:getvalue xmlns:ddcconfig="urn:smuddcconfiguration"> <ddcconfig:network> <ddcconfig:localip>192.168.103.223</ddcconfig:localip> <ddcconfig:globalip>168.188.127.123</ddcconfig:globalip> <ddcconfig:rootbridge>yes</ddcconfig:rootbridge> </ddcconfig:network> </ddcconfig:getvalue>'; $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); ?>
error message is
* connect() 192.168.1.103 port 8080 (#0) * trying 192.168.1.103...
* connected
* server auth using basic user 'lmk'
> put /ew.xml http/1.1
> authorization: basic bg1romfscnvkodk=
> host: 192.168.1.103:8080 accept: /
> transfer-encoding: chunked
> expect: 100-continue
< http/1.1 401 unauthorized
< content-length: 0
<
> www-authenticate: digest qop="auth", realm="mydomain.com", nonce="1366254379"
* http error before end of send, stop sending
* closing connection #0
what problem & solution?
your credentials incorrect! (that's error 401 means)
there's wonderful plugin firefox called poster
- install , use double-check request formatted correctly.
by way, might want add following header:
curl_setopt ($ch, curlopt_httpheader, array("content-type: application/xml"))
another thing: put not supported, try post - it'll work.
Comments
Post a Comment