XBMC-PHP-RPC - a PHP JSON-RPC library supporting HTTP and TCP
#46
Where do you get 10.5? If i download from git, i only get 11.0 PRE, but there json doesn't seem to work.
Reply
#47
11.0 pre works fine for me. Just look at the examples and use the non legacy ones.
Reply
#48
Romep Wrote:Where do you get 10.5? If i download from git, i only get 11.0 PRE, but there json doesn't seem to work.

I honestly can't remember where 10.5 came from! As gugahoi says though it should work with 11.0 too. Bear in mind that the RPC interface in XBMC has been fairly radically updated since Dharma so old commands may not still work. The library itself should function fine though.
Reply
#49
Ok, it works. Don't know what i did. But now i got another problem. I try to GetMovieDetails, but it doesn't accept my parameter? GetMovies runs perfectly.

Code:
$movie = $rpc->VideoLibrary->GetMovieDetails(
                        array(
                            "movieid" => $this->movieid
                        )
        );

$this->movieid is (for example) 292.
Reply
#50
Romep Wrote:Ok, it works. Don't know what i did. But now i got another problem. I try to GetMovieDetails, but it doesn't accept my parameter? GetMovies runs perfectly.

Code:
$movie = $rpc->VideoLibrary->GetMovieDetails(
                        array(
                            "movieid" => $this->movieid
                        )
        );

$this->movieid is (for example) 292.

There is no such thing as GetMovieDetails. I suggest you add a fields parameter to your GetMovies and use that information to show details.
Reply
#51
config_freamwork.php

PHP Code:
<?php


        $host_name 
="localhost"
        
$host_port ="8080";
        
$host_user ="xbmc";
        
$host_pass ="xbmc";


if ( 
$host_port != NULL ){

        
$http_ip      ''.$host_name.':'.$host_port.''

}else{

        
$http_ip      $host_name;

}


$hostjsonrpc  "$http_ip/jsonrpc";
$host_http    "http://$http_ip/";
$host         "$http_ip/";
$host_img     "$http_ip/vfs";
$username     $host_user;
$password     $host_pass;


?>

Framework Core page
PHP Code:
<?php

/* ---------------------------------------------------------------
|
| Inizio parte rigurdante la categoria video . 
|
--------------------------------------------------------------- */


// Funzioni Video Library : film

function film(){

    require(
'config_freamwork.php');
    
    
$json '{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "start": 0, "fields": ["genre", "director", "trailer", "tagline", "plot", "plotoutline", "title", "originaltitle", "lastplayed", "showtitle", "firstaired", "duration", "season", "episode", "runtime", "year", "playcount", "rating" , "file" , "fanart"] }, "id": 1}';
    
    
$chiamata curl_init();
    
curl_setopt($chiamataCURLOPT_RETURNTRANSFER,true);
    
curl_setopt($chiamataCURLOPT_POST          ,1);
    
curl_setopt($chiamataCURLOPT_URL           ,$hostjsonrpc);
    
curl_setopt($chiamataCURLOPT_USERPWD       ,"$username:$password");
    
curl_setopt($chiamataCURLOPT_POSTFIELDS    ,$json);
    
$json curl_exec($chiamata);
    
curl_close($chiamata);    
    return 
$json;
    
    
// id = movie
    
};


            
// Funzioni Video Library : Stagioni TY
            
            
function stagioni(){
            
                require(
'config_freamwork.php');
                
                
$json '{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "start": 0, "fields": ["genre", "director", "trailer", "tagline", "plot", "plotoutline", "title", "originaltitle", "lastplayed", "showtitle", "firstaired", "duration", "season", "episode", "runtime", "year", "playcount", "rating" ,"fanart"] }, "id": 1}';
            
                
$chiamata curl_init();
                
curl_setopt($chiamataCURLOPT_RETURNTRANSFER,true);
                
curl_setopt($chiamataCURLOPT_POST          ,1);
                
curl_setopt($chiamataCURLOPT_URL           ,$hostjsonrpc);
                
curl_setopt($chiamataCURLOPT_USERPWD       ,"$username:$password");
                
curl_setopt($chiamataCURLOPT_POSTFIELDS    ,$json);
                
$json curl_exec($chiamata);
                
curl_close($chiamata);
                return 
$json;
                
                
// id = tvshows
                
            
};
            
                        
// Funzioni Video Library : Stagioni TY --> Episodi
                        
                        
function stagioniepisodi(){
                        
                        
                            require(
'config_freamwork.php');
                            
                            
$json '{"jsonrpc": "2.0", "method": "VideoLibrary.GetSeasons", "params": { "fields": ["genre", "director", "trailer", "tagline", "plot", "plotoutline", "title", "originaltitle", "lastplayed", "showtitle", "firstaired", "duration", "season", "episode", "runtime", "year", "playcount", "rating", "writer", "studio", "mpaa", "premiered" , "fanart"], "tvshowid" : '.$_GET['season'].' }, "id": 1}';
                            
                            
$chiamata curl_init();
                            
curl_setopt($chiamataCURLOPT_RETURNTRANSFER,true);
                            
curl_setopt($chiamataCURLOPT_POST          ,1);
                            
curl_setopt($chiamataCURLOPT_URL           ,$hostjsonrpc);
                            
curl_setopt($chiamataCURLOPT_USERPWD       ,"$username:$password");
                            
curl_setopt($chiamataCURLOPT_POSTFIELDS    ,$json);
                            
$json curl_exec($chiamata);
                            
curl_close($chiamata);
                            return 
$json;
                            
                            
// nome = seasons 
                            // id   = season
                            
                            /*--------------------------------
                            |
                            | ?season=1
                            |
                            --------------------------------*/
                            
                            
                        
};
            
                                        
// Funzioni Video Library : Stagioni TY --> Episodi --> video episodi
                                        
                                        
function stagioniepisodifile(){
                                        
                                        
                                            require(
'config_freamwork.php');
                                            
                                            
$json '{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": { "fields": ["genre", "director", "trailer", "tagline", "plot", "plotoutline", "title", "originaltitle", "lastplayed", "showtitle", "firstaired", "duration", "season", "episode", "runtime", "year", "playcount", "rating", "writer", "studio", "mpaa", "premiered" , "fanart"], "season" : '.$_GET['season'].', "tvshowid" : '.$_GET['episodes'].' }, "id": 1}';
                                            
                                            
$chiamata curl_init();
                                            
curl_setopt($chiamataCURLOPT_RETURNTRANSFER,true);
                                            
curl_setopt($chiamataCURLOPT_POST          ,1);
                                            
curl_setopt($chiamataCURLOPT_URL           ,$hostjsonrpc);
                                            
curl_setopt($chiamataCURLOPT_USERPWD       ,"$username:$password");
                                            
curl_setopt($chiamataCURLOPT_POSTFIELDS    ,$json);
                                            
$json curl_exec($chiamata);
                                            
curl_close($chiamata);
                                            return 
$json;
                                            
                                            
// nome = season
                                            // id   = episodes
                                            
                                            /*--------------------------------
                                            |
                                            | ?season=1&episodes3
                                            |
                                            --------------------------------*/
                                            
                                        
};


// Funzioni Video Library : Video musicali

function videomusicali(){

    require(
'config_freamwork.php');
    
    
$json '{"jsonrpc": "2.0", "method": "VideoLibrary.GetMusicVideos","params": { "start": 0, "fields": ["genre", "director", "trailer", "tagline", "plot", "plotoutline", "title", "originaltitle", "lastplayed", "showtitle", "firstaired", "duration", "season", "episode", "runtime", "year", "playcount", "rating" , "fanart" , "thumbnail" , "artist"] }, "id": 1}';
    
    
$chiamata curl_init();
    
curl_setopt($chiamataCURLOPT_RETURNTRANSFER,true);
    
curl_setopt($chiamataCURLOPT_POST          ,1);
    
curl_setopt($chiamataCURLOPT_URL           ,$hostjsonrpc);
    
curl_setopt($chiamataCURLOPT_USERPWD       ,"$username:$password");
    
curl_setopt($chiamataCURLOPT_POSTFIELDS    ,$json);
    
$json curl_exec($chiamata);
    
curl_close($chiamata);    
    return 
$json;
    
    
// id = files
    
};




?>

Your page

PHP Code:
<?php

    
include ('freamwork_page.php');
    
videomusicali();
    
$curl    videomusicali("$json");
    
    
//echo $curl;
    
    
$array   json_decode($curl,true);
    
$results $array['result']["musicvideos"];
    
    foreach (
$results as $value){ 
    
    
        echo 
$value['label'];
        
    }
    
?>
Reply
#52
samdret Wrote:There is no such thing as GetMovieDetails. I suggest you add a fields parameter to your GetMovies and use that information to show details.

GetMovieDetails does exist, but not in Dharma. It's only available in more recent nightly builds.
Reply
#53
Mindzai Wrote:GetMovieDetails does exist, but not in Dharma. It's only available in more recent nightly builds.

Oh, my bad. That's probably the reason sortmethod won't work on my GetMovies as well? Might have to upgrade to nightly, if your wrapper supports it?
Reply
#54
samdret Wrote:Oh, my bad. That's probably the reason sortmethod won't work on my GetMovies as well? Might have to upgrade to nightly, if your wrapper supports it?

Not sure about the sortmethod - the trouble is that only recent nightly builds properly introspect and the wiki has been updated so afaik the reference for the commands in older versions isn't available anywhere now.

The wrapper should work fine with nightly builds Smile
Reply
#55
How do i add to video playlist?

Code:
$rpc->VideoPlaylist->Add(array("item" => array("movieid" => $this->movieid)));

Doesn't work Sad
Reply
#56
Romep Wrote:How do i add to video playlist?

Code:
$rpc->VideoPlaylist->Add(array("item" => array("movieid" => $this->movieid)));

Doesn't work Sad

try something like

Code:
$rpc->VideoPlaylist->Add(array("movieid" =>$this->movieid));

i have not tested that, but that how the audioplaylist works
Reply
#57
Hi Mindzai,

I just updated to the latest nightly ( XBMCSetup-20110902-312d2c3-master.exe 03-Sep-2011 10:28 ) and your latest Git version ( karlrixon-xbmc-php-rpc-d0dd433 )

When i try the included example.php with the TCP client i get a fatal error, is this combination working for you?
Reply
#58
Hi dann0

I will update to the latest nightly and do some tests.
Reply
#59
I'm sure you will see the problem more clearly than i, but after a quick look i suspect there are a few issues.

The JSON-RPC API dosen't seem to like the format for param, its being sent as null when i think it expects an array.

I dont think the response has an EOF character, the loop waits for a timeout after reading the last chunk (ie: < 512 caracters)

The parser doesn't seem to like the format of the response.. not sure why Smile

I hope you can get to the bottom of it soon, for me the recent updates make it worth updating!
Reply
#60
The client doesn't look for an EOF character (I don't believe the server sends one) but rather counts the { and } characters to determine when the JSON object has been transmitted so I'm not sure why that would have broken. I'm on holiday until next week but when I get back in to work I will update XBMC on my development machine and try to figure these issues out.
Reply

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