1

uTorrentwebUIAPIを使おうとしています。これはかなりn00bの質問だと思いますが、このAPIに関するドキュメントはWeb上にほとんどありません。申し訳ありません。

サーバーはfile_get_contents($ url)を使用しており、必要なデータを取得しています。しかし、私が理解できない形式で。

例えば:

{
    "build": BUILD NUMBER (integer),
    "label": [
        [
            LABEL (string),
            TORRENTS IN LABEL (integer)
        ],
        ...
    ],
    "torrents": [
        [
            HASH (string),
            STATUS* (integer),
            NAME (string),
            SIZE (integer in bytes),
            PERCENT PROGRESS (integer in per mils),
            DOWNLOADED (integer in bytes),
            UPLOADED (integer in bytes),
            RATIO (integer in per mils),
            UPLOAD SPEED (integer in bytes per second),
            DOWNLOAD SPEED (integer in bytes per second),
            ETA (integer in seconds),
            LABEL (string),
            PEERS CONNECTED (integer),
            PEERS IN SWARM (integer),
            SEEDS CONNECTED (integer),
            SEEDS IN SWARM (integer),
            AVAILABILITY (integer in 1/65536ths),
            TORRENT QUEUE ORDER (integer),
            REMAINING (integer in bytes)
        ],
        ...
    ],
    "torrentc": CACHE ID** (string integer)
}

トレントは[a、b、c、d]のようなものです。各トレントはコンマで区切られます

そのため、[a、b、c、d]、[a、b、c、d]、[a、b、c、d]のようなファイルになります。この構造に名前があるかどうかはわかりません。

では、どうすればそれをXMLのようなもっと読みやすいものに変換できますか?ありがとう

4

2 に答える 2

2

It's JSON. You can find the spec and links to parsers for a big pile of languages at http://json.org/

于 2010-10-28T21:13:29.017 に答える
2

It looks like the data is coming back as JSON, which is a simple and popular file-format for exchanging data on the web. You can use PHP's built-in json_decode to parse it into PHP objects or PHP associative arrays.

mixed json_decode ( string $json [, bool $assoc = false [, int $depth =
512 [, int $options = 0 ]]] )

Takes a JSON encoded string and converts it into a PHP variable.

于 2010-10-28T21:13:43.967 に答える