Kodi Community Forum
JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+---- Forum: JSON-RPC (https://forum.kodi.tv/forumdisplay.php?fid=174)
+---- Thread: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC (/showthread.php?tid=68263)



- Briam - 2010-06-06

Thanks for the answer Smile Just got confused cause bram already wrote the method in his java script library but seems he's just guessing Smile


- einhänder - 2010-06-07

jbrennan Wrote:Having a little trouble getting the development webpage to load. I've got a copy of XBMC running which I built from svn, on Mac OS 10.6, and the JSON RPC is working, however when I try to visit http://localhost:8888/development.html I get "File not found" (just text, it's not my browser's error message) (port 8888 is where I'm running xbmc on this machine). If I try get http://localhost:8888/jsonrpc I get the message that it's up and running.

I'm having other issues but I figure I should get this one solved first, as it might solve my other problems.

nearly the same here (linux). if i visit http://ip:8080/development.html i just get a blank page. if i visit http://ip:8080/poc_jsonrpc/development.html i get the "file not found" error.
but all the pages seem to be in place:

Code:
ls -la /usr/share/xbmc/web/
total 84
drwxrwxrwx  3 root root  4096 Jun  6 23:11 .
drwxr-xr-x 11 root root  4096 Jun  6 23:11 ..
-rw-r--r--  1 root root  1706 Jun  6 23:11 albums.html
-rw-r--r--  1 root root  2434 Jun  6 23:11 artists.html
-rw-r--r--  1 root root   793 Jun  6 23:11 basic.css
-rw-r--r--  1 root root  1508 Jun  6 23:11 development.html
-rw-r--r--  1 root root  1878 Jun  6 23:11 help.js
drwxr-xr-x  2 root root  4096 Jun  6 23:11 images
-rw-r--r--  1 root root   383 Jun  6 23:11 index.html
-rw-r--r--  1 root root 17422 Jun  6 23:11 json.js
-rw-r--r--  1 root root  2141 Jun  6 23:11 movies.html
-rw-r--r--  1 root root  3069 Jun  6 23:11 musicfiles.html
-rw-r--r--  1 root root  3517 Jun  6 23:11 nowplaying.html
-rw-r--r--  1 root root  2337 Jun  6 23:11 tvshowepisodes.html
-rw-r--r--  1 root root  1364 Jun  6 23:11 tvshows.html
-rw-r--r--  1 root root  2033 Jun  6 23:11 tvshowseasons.html
-rw-r--r--  1 root root  3057 Jun  6 23:11 videofiles.html

http://ip:8080/jsonrpc gives me the msg "JSONRPC active and working".

EDIT: xbmc.log: http://pastebin.com/FBtmkLPP


- Tolriq - 2010-06-07

Be carefull Smile

It seems that the JS code used is not fully compatible with firefox.

With my firefox 3.6.3 on windows blank page, but works ok on chrome. (No error on firebug on the page don't really know what"s wrong).


- einhänder - 2010-06-07

hehe great. works on safari, too. seems like it's like you said...ff 3.6.3


- Kabooga - 2010-06-09

I'm currently going through the conversion of XBMControl_Web to use the JSON RPC API.

Some issues I'm running into..... (Could be pilot error on my part)
1) A user of my program can go back and forth between the Audio and Video playlists. Currently I am using HTTP API call "SetCurrentPlaylist" to go back and forth. Is there a JSON RPC API call that does this?
2) I see no API call to remove an entry from the playlist. Currently I am using the HTTP API call "RemoveFromPlaylist."
3) I am having a difficult time figuring out how to get the Genre's and Genre ids. Has anybody figured a way of getting these values? My Library functionality really depends on getting the genre information.

Outside the issues mentioned above I have most of XBMControl_Web ported over.

The JSON RPC API is looking really good.

Regards,
Kabooga


- Tolriq - 2010-06-10

Yes genre id is still MIA Smile

Hope to see it implemented as some other request, but since there's no updates on this part and XBMC starting back the official nightly i hope that those will be implemented before a feature freeze.


- marksoccer - 2010-06-21

I was just getting ready to start writing up some php code to interface with the XBMC HTTP API when I noticed this thread. I realize that the json stuff is still being developed, but it looks like it may already have what I need. What I am looking to do is integrate XBMC controls into a website I am creating for a school project. I want to be able to control the music, video and pictures that will be displayed on the media center from the website. It looks like I can do this with the HTTP API, but it looks like I should have more control from the json interface, is this correct? I really like the latest svn web interface's inclusion of pictures for all the movies and albums in xbmc libraries and from my understanding, that is more difficult to accomplish with the HTTP API. However, I have very little experience with javascript and I was looking to control json from PHP. I saw a couple examples of doing this on the web, but I was wondering if someone already has code utilizing the XBMC json interface that they would be willing to share. Also, if anyone has any tips on how they would go about this, I'd love to hear it. Thanks, Mark


- Kabooga - 2010-06-21

There are some codesets you could look at. The best place to look is in the Supplemental Tools for XBMC forum.

Here's a list of some of the work you can look at.

YATSE from Tolriq (.NET) http://code.google.com/p/yatse/

Bram77's excellent Javascript API library http://code.google.com/p/xbmcweb/

Slash's Web Manager http://sourceforge.net/projects/xumm/

XBMControl Web by Me http://code.google.com/p/xbmcontrol-web/

Each of these will give a good basis to start from. Even better is that each developer is easy to contact and very gracious in answering questions.

Good luck.

Cheers,
Kabooga


- Bram77 - 2010-06-21

I'll (finally) be buying myself a nice 42'' lcd and a HTPC (xbmc-linux) after having used the old XBOX with a SD tv for ages. Next month I'll continue development on the xbmcweb JS api and interface and be able to use, test and develop it on a daily basis too.

As Kabooga said, I'll be happy to answer any questions that I have an answer for Smile


- marksoccer - 2010-06-22

Couple more questions? Is the HTTP API in danger of being removed from the code base? After doing some more research, it looks like the bulk of my code will have to be javascript if I go with the json interface (although it looks like a lot of javascript code already exists). I was hoping to just write a wrapper that could call any function from php, but it looks like each php function will have to have a corresponding javascript function. I am considering just using the HTTP API library because it looks more straightforward and easier to use with php. Do you guys have some reasons why I should use json instead of the HTTP API or vice versa?


- jmarshall - 2010-06-22

Yes, the HTTP API will be going away after Dharma most likely.


- marksoccer - 2010-06-22

Ok. I'm glad I asked, I definitely don't want to develop for the HTTP API and then have it disappear. Thanks for the info.


- jmarshall - 2010-06-22

Note that JSON is just a way of formatting up structured data (i.e. objects) into a string - it's like XML in this respect, only more compact.

http://php.net/manual/en/book.json.php

Cheers,
Jonathan


- marksoccer - 2010-06-22

Ok. Yeah, I think I am a little confused. I have seen the php decode and encode methods. What I am confused about is how I actually get the serialized object. It looks like I have to send requests and get responses using javascript. Then, if I want to use php, I can transfer the javascript response to php. I looked at the following code to try to grasp how sending requests and receiving json responses works:

Code:
http_request = new XMLHttpRequest();
http_request.open( "POST", "jsonrpc", false );
http_request.send('{"jsonrpc": "2.0", "method": "' + player + 'Playlist.GetItems", "params": { "fields": ["title", "plot"] }, "id": 1}');

var the_object = JSON.parse(http_request.responseText);

I was hoping to just be able to make some nifty php call, like getCommand("Playlist","GetItems") or something, but it looks like in order to do that, I have to setup the call with javascript and then transfer the result to php and use json_decode() to get a php variable.


- topfs2 - 2010-06-22

Isn't PHP run by the server? the new webserver have no support what so ever for server side scripting Smile