XBMC-PHP-RPC - a PHP JSON-RPC library supporting HTTP and TCP

  Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Mindzai Offline
Fan
Posts: 333
Joined: Aug 2010
Reputation: 0
Post: #16
Ghostface, thanks for the bug report I will look into this today.

darkscout, that isn't my code! Rofl I think you may have the wrong thread Smile
(This post was last modified: 2011-02-11 07:09 by Mindzai.)
find quote
darkscout Offline
Posting Freak
Posts: 2,145
Joined: Jul 2008
Reputation: 12
Post: #17
You are correct Sir. No clue where I got this PHP library from Smile

[Image: aeKO.jpeg]
Code:
GRANT ALL PRIVILEGES ON `xbmc_%`.* TO 'xbmc'@'%';
IF you have a mysql problem, find one of the 4 dozen threads already open.
find quote
Mindzai Offline
Fan
Posts: 333
Joined: Aug 2010
Reputation: 0
Post: #18
@Ghostface

I was unable to reproduce your issue. I added some movies to the database with accented European characters. XBMC always returned UTF-8 encoded responses.

Can you give me some more details about your OS and an example of a movie title which is causing a problem. Could you also please let me know what issue you are having specifically (ie any PHP errors).

I have added some code which will attempt to convert non-UTF-8 encoded string into UTF-8 which may or may not solve your issue, but as I say it's hard for me to confirm as I can't reproduce the issue.
find quote
Ghostface Offline
Junior Member
Posts: 23
Joined: Jun 2008
Reputation: 0
Location: Austria
Post: #19
Nevermind, actually adding utf8_encode messes up regular german chars.

I nailed the problem down to one particular Movie that had strange characters in the filename (so strange they only show up as Confused in my terminal)

after utf8_encoding that filename they resulted in:
Quote:ÔÂÇò

The error message btw was:

Quote:Invalid JSON RPC response

I simply renamed that file and all should be good now.

Thanks for checking tho!
find quote
Mindzai Offline
Fan
Posts: 333
Joined: Aug 2010
Reputation: 0
Post: #20
OK thanks for letting me know Smile
find quote
dann0 Offline
Junior Member
Posts: 29
Joined: Jan 2011
Reputation: 0
Post: #21
Hi Mindzai,

I noticed if i send a request with a string where XBMC is expecting an integer it hangs the JSONRPC interface, i thought maybe you could catch that in your wrapper throwing an exception (or just converting the value to intval).

eg

PHP Code:
$badvar = array('start' => $_POST['start'], 'end' => $_POST['end']);

try{
        
$response $rpc->AudioLibrary->GetArtists($badvar);
} catch(
XBMC_RPC_Exception $e) {
        die(
$e->getMessage());


stops XBMC from responding on the JSON interface.
find quote
Mindzai Offline
Fan
Posts: 333
Joined: Aug 2010
Reputation: 0
Post: #22
dann0 Wrote:Hi Mindzai,

I noticed if i send a request with a string where XBMC is expecting an integer it hangs the JSONRPC interface, i thought maybe you could catch that in your wrapper throwing an exception (or just converting the value to intval).

eg

PHP Code:
$badvar = array('start' => $_POST['start'], 'end' => $_POST['end']);

try{
        
$response $rpc->AudioLibrary->GetArtists($badvar);
} catch(
XBMC_RPC_Exception $e) {
        die(
$e->getMessage());


stops XBMC from responding on the JSON interface.

The issue is that the wrapper doesn't have any way of knowing the correct data type of the parameters of each RPC method, so it would have to convert anything that looked like a number (is_numeric) into the appropriate data type. This may then cause the opposite problem of converting what should be a string into a number.

Personally I think it's either up to the client code, or XBMC itself to handle this sort of thing. I would not anticipate XBMC would hang in this situation myself, I'd expect it to handle type conversion but obviously this isn't the case, so I'd say it's something the client code should do (since by definition you know in client code which method you are calling and what to pass it).

Regarding your other issue with albums not being retrieved correctly when using start and end parameters, I couldn't reproduce the problem. Admittedly my music library on my test machine only has a few albums, but they always came back right with every value of start and end I supplied.
find quote
superflip
Unregistered

Post: #23
Hi,

first of all - thanks to this wonderful Wrapper, it's very helpful.
I've troubles with some methods, when I'm calling the php, i.e.:
Code:
$response = $rpc->AudioPlayer->Stop();
doesn't work for me. I got the error "Failed to execute method."
It is similar for other calls (AudioPlayer.StartPause, ...)

for some methods like all in XBMC namespace
Code:
$response = $rpc->XBMC->play();

I got "Invalid params."

Other calls like both in the example.php works well.
I don't know what I'm doing wrong here.

Can anyone help on this issue or have similar problems?

Thanks,
Philipp
quote
fidoboy Offline
Fan
Posts: 404
Joined: Oct 2008
Reputation: 0
Post: #24
I'm using this:

$result = $xbmcJson->JSONRPC->Announce(array('message' => 'My message', 'sender' => 'testsender'));

but i get an exception 'ERROR: Invalid params'

can anyone confirm this?
find quote
fidoboy Offline
Fan
Posts: 404
Joined: Oct 2008
Reputation: 0
Post: #25
I've solved it adding this line:

Quote:if (is_array($params)) $params = $params[0];

on the first line in rpc function. This way it worked fine... hope this helps to other people having this issue
find quote
Mindzai Offline
Fan
Posts: 333
Joined: Aug 2010
Reputation: 0
Post: #26
@superflip:

I can't reproduce this except for the "Invalid params" response from XBMC->Play(). Not sure why that is as no params are documented for that method. Everything else you mention appears to be working fine here. Can you let me know if you figure out any more info which may point to the cause please?

Edit:

Seems you need to tell it what to play, which makes sense!

PHP Code:
$response $rpc->XBMC->Play(array('file' => 'the\file\path')); 

If you're just trying to play (after pausing for example), you'd need to use VideoPlayer->PlayPause() (or the equivalent for audio and picture players).

@fidoboy:

I can't reproduce your error either. Can you give me the filename and line of where you are editing please?
(This post was last modified: 2011-04-16 00:29 by Mindzai.)
find quote
fidoboy Offline
Fan
Posts: 404
Joined: Oct 2008
Reputation: 0
Post: #27
There is only a function called rpc inside the class xbmcJsonRPC. Locate that function and then add the line in my previous post. I can't remember the name of the file (cause i've renamed it) but there is only one for this library.

You don't need to specify what to play, the parameter is optional. But without my fix, without that line, parameters doesn't work.
find quote
Mindzai Offline
Fan
Posts: 333
Joined: Aug 2010
Reputation: 0
Post: #28
Ah then you're not using my code Smile You must be using another wrapper. I was confused as I already have code to manage varying param configurations.

The only way I could get Play() to work was adding some params specifying what to play. Perhaps the wiki needs to be updated.
(This post was last modified: 2011-04-16 09:36 by Mindzai.)
find quote
claann72 Offline
Junior Member
Posts: 1
Joined: May 2011
Reputation: 0
Post: #29
Hi Mindzai,
I need to contact you via private email. Can you let me know how?

Thanks
find quote
Mindzai Offline
Fan
Posts: 333
Joined: Aug 2010
Reputation: 0
Post: #30
You can reach me by email at karl@karlrixon.co.uk.
find quote