我正在尝试使用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
}
}
}
网址为http://api.tumblr.com/v2/blog/example.tumblr.com/info?api_key=(APIKEY)
我正在尝试获取上面该网址的“帖子”号码。我如何在PHP中执行此操作并仅回显数字?。
答案 0 :(得分:1)
这看起来像一个JSON字符串,所以......
$msg = '{"meta" etc.....';
$data = json_decode($msg);
echo $data['meta']['response']['blog']['posts'];
您可以使用
var_dump($data);
将整个响应转储到格式良好的树结构中。