Click Fraud Protection
PHP related blog, freelancer to hire!

Zend_Test_Client problem with GET parameters in path

Let’s say you want to send REST request to http://test.server.int/articles and your provider requires to send token parameter – but in URL

So your final url will be http://test.server.int/articles?token=12345

My client looked like:

$rest = new Zend_Rest_Client('http://test.server.int');
$rest->restGet('/articles?token=123', array('article' => '<xml>YOUR XML</xml>'));

Fatal error: Uncaught exception ‘Zend_Uri_Exception’ with message ‘Path “/articles?token=123” is not a valid HTTP path’

Solution was simple – your get parameter must be part of URI, not PATH

$rest = new Zend_Rest_Client('http://test.server.int?token=123');
$rest->restGet('/articles', array('article' => '<xml>YOUR XML</xml>'));

Why I didn’t put it into array of arguments? Because for POST request I still wanted to have token as GET param

Leave a Reply