0

我正在尝试使用标签搜索 api 访问为 tumblr 搜索显示的第一张图片的网址。下面是我正在使用的测试搜索的 json。

    {
"meta": {
    "status": 200,
    "msg": "OK"
},
"response": [
    {
        "blog_name": "m00tzman",
        "id": 37918165271,
        "post_url": "http://m00tzman.tumblr.com/post/37918165271/test-image-for-tumblr-a…",
        "slug": "test-image-for-tumblr-api-thingy",
        "type": "photo",
        "date": "2012-12-14 18:13:25 GMT",
        "timestamp": 1355508805,
        "state": "published",
        "format": "html",
        "reblog_key": "IwlKk9r4",
        "tags": [
            "g6845e"
        ],
        "highlighted": [ ],
        "note_count": 29,
        "caption": "<p>test image for tumblr api thingy</p>",
        "photos": [
            {
                "caption": "",
                "alt_sizes": [
                    {
                        "width": 500,
                        "height": 628,
                        "url": "http://25.media.tumblr.com/af60fbe390c487125501e50b37781317/tumblr_…"
                    },
                    {
                        "width": 400,
                        "height": 502,
                        "url": "http://25.media.tumblr.com/af60fbe390c487125501e50b37781317/tumblr_…"
                    },
                    {
                        "width": 250,
                        "height": 314,
                        "url": "http://25.media.tumblr.com/af60fbe390c487125501e50b37781317/tumblr_…"
                    },
                    {
                        "width": 100,
                        "height": 126,
                        "url": "http://24.media.tumblr.com/af60fbe390c487125501e50b37781317/tumblr_…"
                    },
                    {
                        "width": 75,
                        "height": 75,
                        "url": "http://24.media.tumblr.com/af60fbe390c487125501e50b37781317/tumblr_…"
                    }
                ],
                "original_size": {
                    "width": 500,
                    "height": 628,
                    "url": "http://25.media.tumblr.com/af60fbe390c487125501e50b37781317/tumblr_…"
                }
            }
        ]
    }
]

}

我的问题是我无法回显“原始大小”图像的 url。到目前为止,这是我的代码:

    <?php
    $search = file_get_contents('http://api.tumblr.com/v2/tagged?tag=g6845e&api_key=(api key)');
    $tumblrdata = json_decode($search, true);
    $photos = $tumblrdata['photos']['original_size'];
    $url = $photos['url'];
    echo $url;
    ?>

对这里出了什么问题有任何猜测吗?

4

1 回答 1

0

尝试

$photos = $tumblrdata['response']['photos'][0]['original_size'];
于 2012-12-17T04:46:27.403 回答