• 1
  • 21
  • 22
  • 23(current)
  • 24
  • 25
  • 226
JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC
I want to program a php front end to control my XBMC machine. Can anyone here provide me with an example on how to start on this? I tried to capture the result of the GetShares but the array doesn't look very nice. Anyone here knows how to do this so I can use functions like explode and trim.

Code:
<?php
$array = file_get_contents('http://localhost:9019/xbmcCmds/xbmcHttp?command=GetShares(video)');
echo $array;
?>
Reply
I think you are using the old HTTP-API.
The JSON-RPC-API requires that you send a POST-Request with JSON-formatted data.
Have a look at the JavaScript-code of AWX :-)
Reply
Got my first call with php working Smile

Code:
<?php
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_URL, 'http://localhost:9019/jsonrpc');

  //prepare the field values being posted to the service

  $data = '{"jsonrpc": "2.0", "method": "JSONRPC.Version", "id": 1}';
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

  //make the request
  $result = curl_exec($ch);
  echo print_r($data,1); // debugging
  echo print_r($result,1); // debugging
?>
Reply
There is anyway to append at the response a fixed value?

Code:
Code:
HTTP request: {
    id = 0;
    jsonrpc = "2.0";
    method = "VideoLibrary.GetSeasons";
    params =    {
        fields =        (
            season
        );
         [color=red]XXXXXX[/color]
        sortmethod = season;
        sortorder = ascending;
        tvshowid = 12;
    };

For have the followinf response
Code:
JSON result: {
    id = 0;
    jsonrpc = "2.0";
    result =    {
        end = 10;
        seasons =        (
                        {
                label = "Season 1";
                season = 1;
                thumbnail =  [color=red]XXXXXX[/color]special://masterprofile/Thumbnails/Video/9/9bb2a0cd.tbn";
            },
                        {
                label = "Season 10";
                season = 10;
                thumbnail = " [color=red]XXXXXX[/color]special://masterprofile/Thumbnails/Video/6/68c4506f.tbn";
            },
                        {
                label = "Season 2";
                season = 2;
                thumbnail = " [color=red]XXXXXX[/color]special://masterprofile/Thumbnails/Video/9/96f18614.tbn";
            },
        );
        start = 0;
        total = 3;
    };
}

Thanks in advance
Pfeifer
Reply
pfeifer Wrote:There is anyway to append at the response a fixed value?

Thanks in advance
Pfeifer

That's what ID is for, differentiating request/response pairs. Otherwise if it's not for identification then you would append the value AFTER the response comes back.
XBMC Remote7 an XBMC library browser/remote for Windows Phone 7.
Xbmc-Json a .NET XBMC JSON API Library.
Xbmc-Remote-Control a .NET based XBMC library browser and remote for Windows, Linux and OS X.
Reply
is JSON supported in this version:
xbmc-r33778-Dharma_beta2.exe ?

If so, is there anything that I need to do to turn it on, or configure it, or does it use the same settings at the http api on xbmc's system / network window?

it seems that nightly builds are currently disabled. I am not interested in building xbmc myself, but I would like to start playing with json since I am currently using the http-api and would like to move forward when the time comes...

thanks.
Reply
I am working very happy with JsonRpc.

I need to know the workaround for have only the album_artist and not all the artists included for e.g. in compilation where the album_artist is in my case "Various Artists".

How may I modify the following code?

Code:
{"jsonrpc": "2.0", "method": "AudioLibrary.GetArtists", "params": { "start": 0, "sort": { "order": "ascending", "method": "artist" } }, "id": 1}

Thanks
Sandro
Reply
jitterjames Wrote:is JSON supported in this version:
xbmc-r33778-Dharma_beta2.exe ?

If so, is there anything that I need to do to turn it on, or configure it, or does it use the same settings at the http api on xbmc's system / network window?
yes, the Dharma beta2 has JSON-support.
You need to enable the webserver like you do with the old http-api.
Reply
thanks Mkay. Big Grin Got it working now with xbmc remote 0.3 on same machine as xbmc. Hopefully it'll work as well through the lan. I just needed confirmation, because I thought I already had that version of xbmc installed, but apparently I did not!
Reply
Do you know if this is working or not:

Code:
curl -i -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlaylist.Add", "file": "/home/xbmc/Music/Alternative Singles/Air - All I Need.mp3", "id": 1}' http://localhost:9019/jsonrpc

curl -i -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlaylist.GetItems", "id": 1}' http://localhost:9019/jsonrpc

I tried this but the output is always zero, while the response of the first command is:

Code:
{
   "id" : 1,
   "jsonrpc" : "2.0",
   "result" : "OK"
}

return playlist:

Code:
{
   "id" : 1,
   "jsonrpc" : "2.0",
   "result" : {
      "end" : 0,
      "start" : 0,
      "total" : 0
   }
}

Fixed it. Should be:

Code:
curl -i -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlaylist.Add", "params": { "file": "/home/xbmc/Music/Adele - 19/101-adele-daydreams.mp3"}, "id": 1}' http://localhost:9019/jsonrpc
Reply
Question 
<oops wrong post>
Reply
A question;

When I select the song of an album I also want to queue the rest of the songs. How do you deal with that? The song has a songid, so I can I do a for each to queue every other song with a higher songid? Or do I have problems then with names and the order of the songs? What's the best approach for this?
Reply
erhnam Wrote:A question;

When I select the song of an album I also want to queue the rest of the songs. How do you deal with that? The song has a songid, so I can I do a for each to queue every other song with a higher songid? Or do I have problems then with names and the order of the songs? What's the best approach for this?

Song has an album attribute I think. Use that.
XBMC Remote7 an XBMC library browser/remote for Windows Phone 7.
Xbmc-Json a .NET XBMC JSON API Library.
Xbmc-Remote-Control a .NET based XBMC library browser and remote for Windows, Linux and OS X.
Reply
Will the JSON interface allow calling a script with an argument?

I could never get that to work with the http interface, and it would be really sweet!
Reply
jitterjames Wrote:Will the JSON interface allow calling a script with an argument?

I could never get that to work with the http interface, and it would be really sweet!

At some point yeah, I can't see why not.

The reason for it not being there now is mostly that security, while more or less implemented, isn't really turned on. So all insecure stuff (like calling script, alter library) haven't been added yet.
If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

Image

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
Reply
  • 1
  • 21
  • 22
  • 23(current)
  • 24
  • 25
  • 226

Logout Mark Read Team Forum Stats Members Help
JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC8