[SOLVED] Posting XML to a Server Using PEAR HTTP_Request
Posted: Wed Mar 26, 2008 1:20 pm
I need to post xml to a server. The url includes a username, password, and action. I have never done this before so I am trying to use PEAR's HTTP_Request but it is not working. If there is a better way of achieving this, please send me down that direction.
Response...
Code: Select all
$sendURL = 'https://www.domain.com/apps/mod?username=someUser&password=somePass&action=addNote';
$sendData = '<?xml version="1.0" ?>
<Tips>
<Note>
<Id>123456</Id>
<Active>1</Active>
<Text>This is a note.</Text>
</Note>
</Tips>';
$req =& new HTTP_Request($sendURL);
if(!PEAR::isError($req->sendRequest())){
$req->addHeader("Content-Type", "text/xml");
$req->addHeader("Content-Length", strlen($sendData));
$req->setMethod(HTTP_REQUEST_METHOD_POST);
$req->addRawPostData($sendData, true);
$req->sendRequest();
echo "success (".$req->getResponseBody().")";
}
Code: Select all
success (
Request Entity Too Large
The requested resource
/cgi-bin/apavm/apps/mod
does not allow request data with POST requests, or the amount of data provided in the request exceeds the capacity limit.
Request Entity Too Large
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, someone@domain.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
)