Go Back  
Reply
 
Thread Tools
Old 02-18-2013   #1
carldenning
Senior Member
 
Join Date: Jun 2009
Posts: 5,228
Likes: 1,924
Liked 1,847 Times in 1,212 Posts
Mentioned: 224 Post(s)
Tagged: 0 Thread(s)
jsonrpc in php

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($chCURLOPT_CUSTOMREQUEST"POST");
 
curl_setopt($chCURLOPT_POSTFIELDS$data_string);     
 
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
 
curl_setopt($chCURLOPT_HTTPHEADER, array('Content-Type: application/json'));
 
curl_setopt($chCURLOPT_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($chCURLOPT_CUSTOMREQUEST"POST");
 
curl_setopt($chCURLOPT_POSTFIELDS$data_string);     
 
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
 
curl_setopt($chCURLOPT_HTTPHEADER, array('Content-Type: application/json'));
 
curl_setopt($chCURLOPT_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($chCURLOPT_CUSTOMREQUEST"POST");
 
curl_setopt($chCURLOPT_POSTFIELDS$data_string);     
 
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
 
curl_setopt($chCURLOPT_HTTPHEADER, array('Content-Type: application/json'));
 
curl_setopt($chCURLOPT_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
__________________

Last edited by carldenning; 02-18-2013 at 06:22 AM.
carldenning is offline   Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



PS3Hax.net is Copyright © 2010-2013.
Use of this site is governed by our Terms of Use and Privacy Policy. All Trademarks and images are owned by their respected owners.
Posts and links are subject to each author on this forum and are no way affiliated with the operations and/or opinions of ps3hax.net
All times are GMT -5. The time now is 06:55 AM.