Kodi Community Forum
XBMC-PHP - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Web Interfaces (https://forum.kodi.tv/forumdisplay.php?fid=156)
+---- Thread: XBMC-PHP (/showthread.php?tid=157165)



XBMC-PHP - danmedhurst - 2013-02-22

Hi,
I'm struggling to get my head around the JSON-RPC APi and am trying to get some code examples running using XBMC-PHP.

Unfortunately, it doesn't even load.
https://github.com/kaigoh/XBMC-PHP

I've managed to query the API myself using POST but these examples don't seem to work at all.. ANy ideas of what i'm doing wrong or if this is just outdated and there is another PHP Wrapper i should be using?


RE: XBMC-PHP - pkscout - 2013-02-22

That wrapper is horribly out of date. I tried to go through the code to fix all the issues, but I gave up. It seems like the wrapper was being way to agressive about error checking responses. I haven't found another wrapper.

I was trying to do something simple enough that I just did the JSON calls "by hand" in the PHP code by borrowing the small chunk of the wrapper code that actually generates the request. Here's what I am using to do a video library update. Maybe this will help you get started.
Code:
$json = array(
'jsonrpc' => '2.0',
'method'  => 'VideoLibrary.Scan',
'id'      => rand(1, 9999999)
);
$request = json_encode($json);
$url='http://user:[email protected]:8081/jsonrpc';

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$responseRaw = curl_exec($ch);



RE: XBMC-PHP - danmedhurst - 2013-02-23

(2013-02-22, 23:24)pkscuot Wrote: That wrapper is horribly out of date. I tried to go through the code to fix all the issues, but I gave up. It seems like the wrapper was being way to agressive about error checking responses. I haven't found another wrapper.

I was trying to do something simple enough that I just did the JSON calls "by hand" in the PHP code by borrowing the small chunk of the wrapper code that actually generates the request. Here's what I am using to do a video library update. Maybe this will help you get started.
Code:
$json = array(
'jsonrpc' => '2.0',
'method'  => 'VideoLibrary.Scan',
'id'      => rand(1, 9999999)
);
$request = json_encode($json);
$url='http://user:[email protected]:8081/jsonrpc';

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$responseRaw = curl_exec($ch);

Thanks for this, will take a look. Basically what I want is an interface that I can search for movies on, watch the trailers and tell it to play on either of my systems. I have this working perfectly by using php and querying the MySQL database directly. ( unfortunately I keep filling the MySQL tmp folder with too large queries and breaking the recently added videos on xbmc itself.)

The interface is a bit basic but it works and the YouTube lookup for trailers ( it just plays the first result for the movie and year ) but it works great.

Image
Image