hiya everyone , does anyone know about jsonrpc in php please ?
im trying to build a php web interface for xbmc frodo and im stuck .
this bit works fine
ex.php
PHP Code:
<?php
$data = array("jsonrpc" => "2.0", "method" => "VideoLibrary.GetMovies", "params" => array("sort" => array("order" => "ascending", "method" => "label", "ignorearticle" => true), "properties" => array("tagline", "plot", "year", "mpaa", "runtime", "thumbnail", "genre")), "id" => 1);
$data_string = json_encode($data);
$json_url = "http://192.168.1.5:8080/jsonrpc?request=";
$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_URL, $json_url);
$array = json_decode(curl_exec($ch),true);
$results = $array['result']['movies'];
foreach ($results as $value){
if($value['thumbnail'] != "") {
$thumbnail = $value['thumbnail'];
$id = $value['movieid'];
echo '<A HREF="moviedetail.php?id=' . $id . '"><img src="http://192.168.1.5:8080/image/', urlencode($thumbnail), '" width="150" height="250"></A>';
} else {
$thumbnail = $value['thumbnail'];
echo '<A HREF="moviedetail.php?id=' . $id . '"><img src="http://192.168.1.5:8080/image/', urlencode($thumbnail), '" width="150" height="250"></A>';
}
}
?>
the part i'm stuck on is this
moviedetail.php
PHP Code:
<?php
if ($_GET['id'] == null) {
header("Location: ex.php");
exit;
}
else {
$test = $_GET['id'];
$data = array("jsonrpc" => "2.0", "method" => "VideoLibrary.GetMovieDetails", "params" => array("movieid" => intval($test), "properties" => array("tagline", "plot", "year", "mpaa", "runtime", "thumbnail", "genre", "imdbnumber")), "id" => 1);
$data_string = json_encode($data);
$json_url = "http://192.168.1.5:8080/jsonrpc?request=";
$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_URL, $json_url);
$array = json_decode(curl_exec($ch),true);
$results = $array['result']['moviedetails'];
print_r($results);
}
?>
how would i do sort of the same as the 1st part but for a single request not eg
PHP Code:
($results as $value){
so i can get the info for the film selected
thanks

************* [ - Post Merged - ] *************
ive worked it out.
Here its the edit part for the 2nd bit , thought i post the answer in case someone wants to start building there own
PHP Code:
<?php
if ($_GET['id'] == null) {
header("Location: ex.php");
exit;
}
else {
$test = $_GET['id'];
$data = array("jsonrpc" => "2.0", "method" => "VideoLibrary.GetMovieDetails", "params" => array("movieid" => intval($test), "properties" => array("tagline", "plot", "year", "mpaa", "runtime", "thumbnail", "genre", "imdbnumber")), "id" => 1);
$data_string = json_encode($data);
$json_url = "http://192.168.1.5:8080/jsonrpc?request=";
$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_URL, $json_url);
$array = json_decode(curl_exec($ch),true);
$results = $array['result']['moviedetails'];
if($results['thumbnail'] != "") {
$thumbnail = $results['thumbnail'];
$num = $results['movieid'];
$plot = $results['plot'];
echo $plot;
echo '<img src="http://192.168.1.5:8080/image/', urlencode($thumbnail), '" width="150" height="250"></A>';
} else {
$thumbnail = $value['thumbnail'];
echo $plot;
echo '<img src="http://192.168.1.5:8080/image/', urlencode($thumbnail), '" width="150" height="250"></A>';
}
}
?>
just had to remove this to get it working
PHP Code:
foreach ($results as $value){
, i am stupid sometimes lol