CodeIgniter Forums
JSON-RPC Library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: JSON-RPC Library (/showthread.php?tid=13783)

Pages: 1 2


JSON-RPC Library - El Forum - 05-28-2010

[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.


JSON-RPC Library - El Forum - 01-20-2011

[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.


JSON-RPC Library - El Forum - 03-03-2011

[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?


JSON-RPC Library - El Forum - 05-26-2011

[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!


JSON-RPC Library - El Forum - 05-26-2011

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

http://nickol.us/code/

and as attach


JSON-RPC Library - El Forum - 05-26-2011

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

http://nickol.us/code/

and as attach[/quote]

Thank you.


JSON-RPC Library - El Forum - 05-26-2011

[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


JSON-RPC Library - El Forum - 08-16-2011

[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?