Hello,
I'm attempting to use Zend_Rest for posting an XML request document and
receiving a response. Basically I'm attempting to do the following with
Zend_Rest:
function do_post_request($url, $data, $optional_headers
= null){
$params = array('http' => array(
'method' => 'POST',
'content' => $data
));
if( $optional_headers !== null )
$params['http']['header'] = $optional_headers;
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if( !$fp )
throw new
Exception("Problem with $url, $php_errormsg");
$response = @stream_get_contents($fp);
if( $response === false )
throw new
Exception("Problem reading data from $url, $php_errormsg");
return $response;
}
In that function the $data parameter is the XML request document - the
returned response is an XML document.
Here is what I've got using the Zend framework so far:
public function getResponse(){
$requestDoc = $this->_RSR->generateRequest();
$this->_rest = new
Zend_Rest_Client('https://full_url/goes_here');
//$result = $this->_rest->post($requestDoc);
$result =
$this->_rest->post('https://full_url/goes_here', $requestDoc);
return $result;
}
With the first way of calling the post I get a URI exception - so I put
the url as the first parameter, and the document as the second and then
I apparently get some sort of response (though not the expected XML
response), and that response causes simplexml_load_string to spit out
MANY errors.
Anybody know how I can do what I'm looking to do? Maybe Zend_Rest isn't
the correct component - but I would like to use something in the Zend
Framework.
Thanks,
Chris Kolkman