[Solar-talk] Sungrazr_Server: Request for comments
Rodrigo Moraes
rodrigo.moraes at gmail.com
Sat Mar 8 14:41:01 CST 2008
On Tue, Dec 18, 2007 at 8:53 PM, Clay Loveless wrote:
> If anyone is interested, I'm implementing an abstracted web services
> server for Solar, which is similar (at least in theory) to Zend_Server
> and bits in Zend Framework that inherit from it, such as
> Zend_Rest_Server.
Hey Clay,
I started to try it, and I'm still very new to these classes. First, I
had to update a few lines in Sungrazr to use Solar 1.0.0alpha
(Solar_Registry and Solar_File calls, basically). Then I've setup an
example like yours, but using Solar_Http_* classes. I created a
directory for the server, set a bootstrap and an Api class, and then
called the example code from somewhere else. Well, the server worked,
and broke on a XML-RPC validation. My code:
$url = 'http://api.tipos';
$call = array(
'method' => 'stuff.create',
'params' => array(
array('apikey' => 'foo'),
array('properties' => array(
'first_name' => 'John',
'last_name' => 'Public',
)),
),
'id' => 55,
);
$json = Solar::factory('Solar_Json');
$call = $json->encode($call);
$request = Solar::factory('Solar_Http_Request', array(
'content_type' => 'application/json',
));
$response = $request->setUri($url)
->setMethod('post')
->setContent($call)
->fetch();
$code = $response->getStatusCode();
$msg = $response->content;
Solar::dump($code);
Solar::dump($msg);
The dumped code was:
int(200)
string(162) "{"result":null,"error":{"name":"JSONRPCError","code":400,"message":"JSON-RPC
does not support Content-Type application\/json; charset=utf-8
requests."},"id":null}"
It seems that the call to $this->_request->server('CONTENT_TYPE',
'unknown') is returning 'application\/json; charset=utf-8', while it
expects just 'application/json'.
Do you have an idea of what may I have done wrong?
I may test other adapters later. Sorry for the newbie problem. :)
thanks,
rodrigo
More information about the Solar-talk
mailing list