project page: http://drupal.org/sandbox/redsd/1404920
git repository: http://git.drupal.org/sandbox/redsd/1404920.git
drupal: 7

I created this module in a effort to reduce time spent on setting up a method that allows other websites and/or mobile systems to communicate with drupal websites. I hope I can help other people making this easier.

The module allows to connect your own function to methodes, that can then be called through the JSON-RPC connection. A user can only make a connection if he has a valid user account and the right role that is connected to the service.

The modules allows other modules to easily extend on methodes, so developer can focus on writing their modules that need to cooperate with the JSON-RPC methodes. An module is included that allows to view, load, save and delete nodes. Use this as an example on how to extend the module.

This modules differs from the services module, since it's only focussed on JSON-RPC and works out of the box. Also I tried to keep it easy for other developers to create there own modules that allow them to interact with other devices/websites.

I separated the roles of the user from the roles of the JSON-RPC client, this way, if needed a user won't be able to access a drupal admin but still could have access to the JSON-RPC methods.

CommentFileSizeAuthor
#1 drupalcs-result-1413020.txt22.11 KBchertzog

Comments

chertzog’s picture

StatusFileSize
new22.11 KB

There are still files other than README.txt in the master branch, make sure to remove them. See also step 5 in http://drupal.org/node/1127732
Review of the 7.x-1.x branch:

  • README.txt is missing, see the guidelines for in-project documentation.
  • ./simple_json_rpc_server.install: all functions should be prefixed with your module/theme name to avoid name clashes. See http://drupal.org/node/318#naming
    function json_rpc_server_schema() {
    
  • ./json_rpc_server_node/json_rpc_server_node.module: all functions should be prefixed with your module/theme name to avoid name clashes. See http://drupal.org/node/318#naming
    function json_rpc_server_node_jsonrpc_services() {
    function json_rpc_server_node_nodeload($nid) {
    function json_rpc_server_node_nodeview($nid, $view_mode = 'full', $langcode = NULL) {
    function json_rpc_server_node_nodesave($arNode) {
    function json_rpc_server_node_nodedelete($nid) {
    
  • Remove all old CVS $Id tags, they are not needed anymore.
    json_rpc_server_node/json_rpc_server_node.info:1:; $Id$
    
  • Drupal Code Sniffer has found some code style issues (please check the Drupal coding standards). See attachment.

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. Get a review bonus and we will come back to your application sooner.

chertzog’s picture

Status: Needs review » Needs work
redsd’s picture

-Okay I cleanend up the master branch
-Added a readme.txt to the other module
-renamed the functions
-removed old cvs tag

The code sniffer thing I can't fix, it tells me I can't use t() in description in menu, but drupal documentation recommends using t() in description. The other error is that I need to use 2 spaces in a array however this will make the code look like a mess since it needs to be more then 2 spaces.

I will look in the other whitespaces warnings/errors.

redsd’s picture

Status: Needs work » Needs review

Okay fixed everything that was indicated PAReview.sh, however the program keeps saying there are files in the master branch.

I checked in git, using: "git ls-tree -r --name-only master" and this indicates that only the README.txt is present.

operinko’s picture

Status: Needs review » Needs work

There are still files other than README.txt in the master branch, make sure to remove them. See also step 5 in http://drupal.org/node/1127732
Review of the 7.x-1.x branch:

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. Get a review bonus and we will come back to your application sooner.

Source: http://ventral.org/pareview - PAReview.sh online service

Those files can be seen here:
http://drupalcode.org/sandbox/redsd/1404920.git/tree/refs/heads/master

Manual review:
redsd’s picture

Status: Needs work » Needs review

I was a bit low on time last month or so.

I experienced some problems with Git not getting my files deleted from master,
however I finnaly succeeded so only the readme file is present in the master branch now.

Menu items are broken. (http://admin/config/services/jsonrpc/#/methods, instead of http://url/admin/...)

This I don't understand, what is wrong with the menu items, I compared them with other drupal modules and I don't seem to be missing anything.

operinko’s picture

It has to do with your use of base_path() in hook_form().

http://api.drupal.org/api/drupal/includes!common.inc/function/base_path/7
Returns the base URL path (i.e., directory) of the Drupal installation.

So:
http://example.com returns "/" because the path is empty.

Simple fix (don't know if it's the best fix, but works for me):
Add:
global $base_url; to the top of the hook_form() function.

Edit $url variable to:
$url = $base_url . base_path() . current_path();

operinko’s picture

Status: Needs review » Needs work

Changing to needs work, since the links are still broken (atleast for me).

redsd’s picture

Status: Needs work » Needs review

Thank you operinko, I didn't noticed this is as problem, changed the url layout to your example.

acobot’s picture

Status: Needs review » Needs work

Great module,

1. I think more instruction about how to extend the API should be added.
2. Why there is only a POST request method allowed, I think GET method is commonly used, for example fetching the data from server and render in web page. Others are PUT/DELETE
3. I think the methods list should be kept private.

Regards

redsd’s picture

I like those ideas,
I could make it an option how to (not) show the method list, this way all available methods can be shown in the way the users wants to.

operinko’s picture

Sorry for not checking back earlier, have been busy with work.
Possibly due to the latest changes you've done, code review throws some errors.

http://ventral.org/pareview/httpgitdrupalorgsandboxredsd1404920git

1.) Do not use t() in hook_menu(). You've done so on 6 lines in simple_json_rpc_server.module
2.) You've got a bunch of comments that are longer than 80 chars, split them on multiple lines.
3.) Comments should always end in a full stop. Also, function docblock short description should be on one line.
4.) Make sure you have a space between operator and it's variables (wrong example: if($something) & correct example: if ($something))
5.) Also, your indentation is faulty in some places (simple_json_rpc_server.module and simple_json_rpc_server_node.module).

Apart from those issues found with an automated code review, I couldn't find any problems during a manual code crawl & test.
Fix those, and it's RTBC by me :)

redsd’s picture

Due to my personal live has cought up with me, I will hope to find sometime in the near future to continue this. For now I can't get the time nor the feel to start it up again.

patrickd’s picture

Status: Needs work » Postponed

Okay, feel free to come back whenever you like !

klausi’s picture

Status: Postponed » Closed (won't fix)

Closing due to lack of activity. Feel free to reopen if you are still working on this application.