Welcome Guest, Not a member yet? Register   Sign In
JSON-RPC Library
#11

[eluser]debonair[/eluser]
Hi Nick,

I am also interested in the Libray and the documentation, can't seem to get it right, please post some sample server and client code.
#12

[eluser]alexanderweiss[/eluser]
Great library!
For the people asking for more documentation/example code.

It works fine for me in this way:

Code:
<?php

class Pages extends Controller {

    function Pages()
    {
        parent::Controller();    
        $this->load->library('jsonrpc');
        $this->load->model('pagesmodel');
        $this->server = $this->jsonrpc->get_server();
        $methods = array(
          'contentList' => array('function' => 'Pages.contentList', 'summary' => 'Returns a contentList of pages.'),
          'updateContentListOrder' => array('function' => 'Pages.updateContentListOrder', 'summary' => 'Updates the order of pages and groups according to the passed array.')
    );
        $this->server->define_methods($methods);
        $this->server->set_object($this);
        $this->server->serve();
    }
    
    function index()
    {
    
    }
    
    function contentList()
    {  
      return $this->server->send_response($this->pagesmodel->get_all_pages());
    }
    
    function updateContentListOrder($order)
    {
       return $this->server->send_response($this->pagesmodel->update_order($order));
    }
}

I then do a JSON-RPC request like the following:
Code:
{"method":"contentList","params":null,"id":"gj5rqzrz"}

Or:
Code:
{"method":"updateContentListOrder","params":[{"id":"2","groupID":false},{"id":"7","groupID":"2"},{"id":"6","groupID":"2"},{"id":"5","groupID":"2"},{"id":"1","groupID":false},{"id":"8","groupID":"1"},{"id":"2","groupID":"1"},{"id":"4","groupID":"1"},{"id":"1","groupID":"1"}],"id":"gj5rxe12"}

In the first method my model simply returns an array containing object (result of a MySQL query).
For the second method the model takes an array of objects (as seen in the call) and returns true or false.

That's all there's to it. I hope it helps.
#13

[eluser]petroz[/eluser]
[quote author="Nick Husher" date="1228517712"]After a little poking around, I realized that there's no JSON-RPC library for CodeIgniter. In fact, the state of JSON-RPC libraries for PHP is pretty sad. I decided to rectify that for CI, at least, by writing my own JSON-RPC server/client. It behaves similarly to CI's XML-RPC library, so it should be easy to set up if you're familiar with it. The server mostly adheres to the JSON-RPC 1.1 working draft while the client can be used to request JSON data from any source.

CI JSON-RPC 1.0

Readme follows below:[/quote]

The link is dead... Sad Is this still an active library?
#14

[eluser]xoRiZ[/eluser]
[quote author="petroz" date="1299220823"][quote author="Nick Husher" date="1228517712"]After a little poking around, I realized that there's no JSON-RPC library for CodeIgniter. In fact, the state of JSON-RPC libraries for PHP is pretty sad. I decided to rectify that for CI, at least, by writing my own JSON-RPC server/client. It behaves similarly to CI's XML-RPC library, so it should be easy to set up if you're familiar with it. The server mostly adheres to the JSON-RPC 1.1 working draft while the client can be used to request JSON data from any source.

CI JSON-RPC 1.0

Readme follows below:[/quote]

The link is dead... Sad Is this still an active library?[/quote]

If someone has this library; please archive and reply. I would like to update and host.

Thanks!
#15

[eluser]Unknown[/eluser]
There you go Smile

http://nickol.us/code/

and as attach
#16

[eluser]xoRiZ[/eluser]
[quote author="l3to" date="1306432636"]There you go Smile

http://nickol.us/code/

and as attach[/quote]

Thank you.
#17

[eluser]dUspan[/eluser]
hi

im still confused with this library.

can you pls make a complete basic code using this library and
zip or post it here?i really want to learn this library Big Grin

much better if you insert an sql query to json format.

thanks
#18

[eluser]searain[/eluser]
Thanks!

This library works.

How about codeigniter 2? Does it have built in json rpc library? or is there a 3rd party json rpc library for CI2?




Theme © iAndrew 2016 - Forum software by © MyBB