0

Tumblrs API を使用しようとしています。API の URL にアクセスすると、以下のようになります。

{
    "meta": {
        "status": 200
        "msg": "OK",
    },
    "response": {
        "blog": {
            "title": "Ex-Sample",
            "posts": 20,
            "name": "example",
            "url": "http://example.tumblr.com/",
            "updated": 1327794725,
            "description": "A sample document used to provide examples of the various [and <i>varying</i>] HTML tags Tumblr puts out. Quote, specifically, has a lot of variants.",
            "ask": false
        }
    }
}

URL はhttp://api.tumblr.com/v2/blog/example.tumblr.com/info?api_key=(APIKEY )です。

上記のURLで「投稿」番号が何であるかを取得しようとしています。PHP でそれを行うにはどうすればよいですか?

4

1 に答える 1

1

それはJSON文字列のように見えるので...

$msg = '{"meta" etc.....';
$data = json_decode($msg);
echo $data['meta']['response']['blog']['posts'];

使用できます

var_dump($data);

きれいにフォーマットされたツリー構造で応答全体をダンプします。

于 2012-05-01T20:46:46.813 に答える