[ALL] HTTPAPI to retrieve current status?

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
realjobe Offline
Posting Freak
Posts: 982
Joined: Sep 2004
Reputation: 0
Post: #1
Hi there.
Using Eden RC2 at the moment on Win7 platform.

Is there more structured way to ask XBMC what is the system now playing besides
Code:
http://ip:port/xbmcCmds/xbmcHttp?command=getcurrentlyplaying
? This will result <html><li>.... structure and is not the best way to parse thing out from it: Movies,Files and TV shows have different out structure.

XWMM looks really good but just need to ask what the system is playing at given time.. that needs to be lite.
XML-out format could be nice.

EDIT: JSON RPC?
http://wiki.xbmc.org/index.php?title=JSON_RPC
RestClient? This is overkill for me. Smile Have to make this happen with PHP5.x... Any help?

edit: Ok, Found one PHP Rest Client https://github.com/educoder/pest and
Api is http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v3

Smile
(This post was last modified: 2012-03-16 12:59 by realjobe.)
find quote
realjobe Offline
Posting Freak
Posts: 982
Joined: Sep 2004
Reputation: 0
Post: #2
For Chrome & FireFox there are great Rest Client (from Chao ZHOU).
Can anyone give some pointer of how to query.. anything..
find quote
realjobe Offline
Posting Freak
Posts: 982
Joined: Sep 2004
Reputation: 0
Post: #3
Using Eden RC2.

So, with POST method to http://<your-ip>::<configured port>/jsonrpc. (JSON-RPC API v4 (Eden))?

In the data area comes the "payload" i.e. query, but must the Http header also be filled with ... mime?
(This post was last modified: 2012-03-20 12:16 by realjobe.)
find quote
realjobe Offline
Posting Freak
Posts: 982
Joined: Sep 2004
Reputation: 0
Post: #4
Can anyone give even a small hint on how to Query with fox/chrome's Rest client something.. player status?
find quote
realjobe Offline
Posting Freak
Posts: 982
Joined: Sep 2004
Reputation: 0
Post: #5
ok.. I got FireFox REST client to work..sort of.. Xbmc v11.0

REST Method = POST,
Code:
http://ip:port/jsonrpc
RequestBody =
Code:
{"jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1}
and result is

Code:
{"id":1,"jsonrpc":"2.0","result":[{"playerid":1,"type":"video"}]}

(DVD movie is playing)
So the playerID is 1.

How to ask for the name of the movie playing?
find quote
realjobe Offline
Posting Freak
Posts: 982
Joined: Sep 2004
Reputation: 0
Post: #6
Well..
Code:
{ "jsonrpc": "2.0", "method": "Player.GetItem", "params": { "playerid": 1, "properties": ["title"] }, "id": 1 }
Seems to work.. TV-Series, Video and Movies show different result


Refering to Here
find quote
realjobe Offline
Posting Freak
Posts: 982
Joined: Sep 2004
Reputation: 0
Post: #7
For PHP implementation use This RESTClient

Ping is
Code:
$JSON = array(
    "jsonrpc"=>"2.0",
    "method"=>"JSONRPC.Ping",
    "id"=>"1"
    );
$ping = RestClient::post("http://ip:port/jsonrpc",json_encode($JSON,true),"","","application/json");

Dump the result into array..
Code:
var_dump(json_decode($ping->getResponse(), true));

Result is
Code:
array(3) { ["id"]=> string(1) "1" ["jsonrpc"]=> string(3) "2.0" ["result"]=> string(4) "pong" }
(This post was last modified: 2012-04-13 15:01 by realjobe.)
find quote
realjobe Offline
Posting Freak
Posts: 982
Joined: Sep 2004
Reputation: 0
Post: #8
I did it. I have fully functional PHP implementation to ask for current playing movie/tv-series/video.
So it's doable.
Smile
find quote
sirkingchase Offline
Junior Member
Posts: 19
Joined: Jun 2012
Reputation: 0
Post: #9
(2012-04-18 17:21)realjobe Wrote:  I did it. I have fully functional PHP implementation to ask for current playing movie/tv-series/video.
So it's doable.
Smile

Can you post your PHP code? I am trying to do something simular, http://forum.xbmc.org/showthread.php?tid=133695

My problem right now is I have live streams that start as paused ( to buffer), if I press play if will turn off my monitor. My goal is to convert my PHP HTTP code into a json, then make it all a plugin. I need to retrieve the status of XBMC and if it is not play and my monitor is on then I dont need it to turn my monitor off.
find quote