XBMC-PHP-RPC - a PHP JSON-RPC library supporting HTTP and TCP
#61
holidays... lucky you Smile

Its fgets() that is timing out, and its not EOF thats missing from the response (i guess we don't expect one using TCP) its 'new line'. When i look at the raw response using telnet, the cursor moves to the next line using XBMC ver 10.1 but does not using the nightly version.

I will bring it up in the JSON-RPC thread and hopefully by the time you get back this part of the problem will be solved.
Reply
#62
That would make sense. If it's intended behaviour from the server I can work around it, but I'll wait and see what the devs say before I do anything in case it's a bug on the server's end.
Reply
#63
Ok, word is its not a bug, but intended behaviour see here

I might try making a feature request to allow a forced EOL char at the end of the response, but i guess realistically a workaround will be required... fgetc() perhaps, but that seems to be somewhat inefficient.

I'm looking forward to seeing what you come up with!
Reply
#64
Hi,

This is great. A very useful wrapper. I have used it it write a script to tweet the currently playing Movie/TvShow.

I would like to call this every time a new video is started. Is there any easy ways to get the JSON announcements that xbmc sends across the TCP port?

If I telnet into port 9090 I get notification when playback starts

{
"jsonrpc" : "2.0",
"method" : "Announcement",
"params" : {
"message" : "PlaybackStarted",
"sender" : "xbmc"
}
}

Is there a way to read this using this wrapper?
If not is there a way to implement this.

Thanks
Reply
#65
dann0 Wrote:Ok, word is its not a bug, but intended behaviour see here

I might try making a feature request to allow a forced EOL char at the end of the response, but i guess realistically a workaround will be required... fgetc() perhaps, but that seems to be somewhat inefficient.

I'm looking forward to seeing what you come up with!

Apologies for the delay I have pushed a change for this. Could you please let me know if it fixes your problem?

torianironfist Wrote:Is there any easy ways to get the JSON announcements that xbmc sends across the TCP port?

It is certainly possible to write a listening client to do this, however using it would block any further activity. For this reason it would have to write to a buffer of some sort (file based I would guess as reading and writing session data without completing an HTTP request in between will not work) which is then read via an AJAX request from the client code. I guess on a LAN this would be speedy enough, but obviously there is the HTTP overhead etc. I would have to do some testing to ensure it could be done fast enough to be useful.

Unless anyone has any better suggestions?
Reply
#66
Do you have any plans of supporting Eden with this wrapper?
Reply
#67
How to get this to work with eden?
Reply
#68
My fault. Should have updated the files. TCP is a lot slower than HTTP, cause it has to read each character instead of a whole line. Any chance to get it faster again?
Reply
#69
Is this wrapper support v6 prodo?
Iv made some tests and looks like im passing wrong params for example

The object desciption show

Player.Open
Start playback of either the playlist with the given ID, a slideshow with the pictures from the given directory or a single file or an item from the database.

array(4) { ["description"]=> string(158) "Start playback of either the playlist with the given ID, a slideshow with the pictures from the given directory or a single file or an item from the database." ["params"]=> array(1) { [0]=> array(2) { ["name"]=> string(4) "item" ["type"]=> array(3) { [0]=> array(3) { ["additionalProperties"]=> bool(false) ["properties"]=> array(2) { ["playlistid"]=> array(2) { ["$ref"]=> string(11) "Playlist.Id" ["required"]=> bool(true) } ["position"]=> array(2) { ["$ref"]=> string(17) "Playlist.Position" ["default"]=> int(0) } } ["type"]=> string(6) "object" } [1]=> array(1) { ["$ref"]=> string(13) "Playlist.Item" } [2]=> array(3) { ["additionalProperties"]=> bool(false) ["properties"]=> array(3) { ["path"]=> array(2) { ["required"]=> bool(true) ["type"]=> string(6) "string" } ["random"]=> array(2) { ["default"]=> bool(true) ["type"]=> string(7) "boolean" } ["recursive"]=> array(2) { ["default"]=> bool(true) ["type"]=> string(7) "boolean" } } ["type"]=> string(6) "object" } } } } ["returns"]=> array(1) { ["type"]=> string(6) "string" } ["type"]=> string(6) "method" }
Playe

And

[ code ]
$response = $rpc->Player->Open(array('file' => '/home/media/anything_else.avi'));
[ code ]

gives me

PHP Fatal error: Uncaught exception 'XBMC_RPC_ResponseException' with message 'Invalid params.' in xbmc-php-rpc-master\rpc\Response.php:27
Stack trace:
#0 \rpc\Client.php(320): XBMC_RPC_Response->__construct('{"error":{"code...')
#1 \rpc\Client.php(96): XBMC_RPC_Client->sendRpc('Player.Open', Array)
#2 \rpc\Command.php(63): XBMC_RPC_Client->executeCommand(Object(XBMC_RPC_Command))
#3 \rpc\Namespace.php(79): XBMC_RPC_Command->execute(Array)
#4 xbmc.php(65): XBMC_RPC_Namespace->__call('Open', Array)
#5 xbmc.php(65): XBMC_RPC_Namespace->Open(Array)
#6 {main}
thrown in xbmc-php-rpc-master\rpc\Response.php on line 2
7
Reply
#70
I'm trying to use the HTTPClient from example.php. It won't work with JSON-RPC API v6 (Frodo) because according to the wiki, it now needs the "Content-Type" header.

I fixed it (at least for the example.php) by adding the following line in HTTPClient.php, around line 97 (sendRequest):
PHP Code:
curl_setopt($this->curlResourceCURLOPT_HTTPHEADER, array('Content-Type: application/json')); 

Forked & fixed here: https://github.com/chaka2828/xbmc-php-rpc
Merged by author: https://github.com/karlrixon/xbmc-php-rpc

EDIT: changed "v6" to "JSON-RPC API v6 (Frodo)" + fork + merge
Reply
#71
(2012-12-24, 13:47)ranpow Wrote: [...]
Player.Open
Start playback of either the playlist with the given ID, a slideshow with the pictures from the given directory or a single file or an item from the database.
[...]
Try
PHP Code:
$rpc->Player->Open(array('item' => array('path' => '/home/media/anything_else.avi'))); 
Reply

Logout Mark Read Team Forum Stats Members Help
XBMC-PHP-RPC - a PHP JSON-RPC library supporting HTTP and TCP1