2014-12-23 1 views
2

rtorrent 정보를 얻을 ...PHP는 xmlrcp 클라이언트 내 rtorrent 인스턴스의 일부 정보를 얻기를 위해 간단한 PHP 스크립트를 작성해야

이는 ... 내가 코드를 많이 시도하지만 난 결코 responce을주지 내 마지막 테스트

ini_set('display_errors', 1); 
error_reporting(E_ALL); 

function do_call($host, $port, $request) { 

    $url = "http://$host:$port"; 
    $header[] = "Content-type: text/xml"; 
    $header[] = "Content-length: ".strlen($request); 

    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_TIMEOUT, 1); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $request); 

    $data = curl_exec($ch); 
    if (curl_errno($ch)) { 
     print curl_error($ch); 
    } else { 
     curl_close($ch); 
     return $data; 
    } 
} 

$host = '127.0.0.1'; 
$port = 10001; 
$request = xmlrpc_encode_request("system.listMethods()", null); 
$response = do_call($host, $port, $request); 
var_dump($response); 

간단한 테스트 코드가 있습니까?

답변

2

이것은 PHP-XMLRPC의 버그입니다.

당신이 당신의 라인을 대체 할 수있다 그러나 :와

$data = curl_exec($ch); 

: 예상대로

$data = xmlrpc_decode(str_replace('i8>', 'i4>', curl_exec($ch))); 

이 작업을해야합니다.

관련 문제