private function loadAvailableCommands() {
try {
$response = $this->sendRpc('JSONRPC.Introspect');
} catch (XBMC_RPC_Exception $e) {
throw new XBMC_RPC_RequestException(
'Unable to retrieve list of available commands: ' . $e->getMessage()
);
}
private function loadAvailableCommands() {
try {
$response = $this->sendRpc('JSONRPC.Introspect',
array('getdescriptions' => 'True', 'getmetadata' => 'False'));
} catch (XBMC_RPC_Exception $e) {
throw new XBMC_RPC_RequestException(
'Unable to retrieve list of available commands: ' . $e->getMessage()
);
}
搞定。
2、中文乱码,继续debug,发现在这个函数之前字符是正确的。
/**
* Takes a JSON string as returned from the server and decodes it into an
* associative array.
*/
private function decodeResponse($json) {
if (extension_loaded('mbstring')) {
$encoding = mb_detect_encoding($json,
'ASCII,utf-8,ISO-8859-1,windows-1252,iso-8859-15');
if ($encoding && !in_array($encoding, array('utf-8', 'ASCII'))) {
$json = mb_convert_encoding($json, 'utf-8', $encoding);
}
}
$r = json_decode($json, true);
return $r;
}
/**
* Takes a JSON string as returned from the server and decodes it into an
* associative array.
*/
private function decodeResponse($json) {
if (extension_loaded('mbstring')) {
$encoding = mb_detect_encoding($json,
'ASCII,utf-8,ISO-8859-1,windows-1252,iso-8859-15');
if ($encoding && !in_array($encoding, array('utf-8', 'ASCII'))) {
$json = mb_convert_encoding($json, 'utf-8', 'auto');
}
}
$r = json_decode($json, true);
return $r;
}