I have a script where I want to post some json to another site and then handle 
the return value. This will not just be returning a JSON value to a browser.

I was thinking of using cURL but figured I'd try Zend_Http_Client. Originally, 
was going to use setRawPost but other developer would prefer just a straight 
variable named data and then will grab and process via JSON parser on his end. 

I have some code like this:
        $output=json_encode($result);
        $client = new Zend_Http_Client('http://www.server.com/json/write.php', 
array(
            'maxredirects' => 0,
            'timeout'      => 30));
        //$client->setHeaders('content-type: text/json');
        $client->setParameterPost('data',$output);
        $client->request();


I get the following error msg: there was an error Cannot handle content type '' 
automatically. Please use Zend_Http_Client::setRawData to send this kind of 
content.

This happens whether the I have set the content/type via the commented out line 
(or application/json or application/javascript). I would think since I'm 
assigning it to a standard post variable, that text/html would work - I'm 
assuming this is the default.

How should I be doing this? Is it just easier to use cURL. 

I could see doing more of this in the future and would just like to know what 
the best practice is.

thanks,

j



      

Reply via email to