【发布时间】:2012-05-02 15:54:09
【问题描述】:
我正在尝试使用 Tumblr API,我相信它的 JSON。我正在尝试使用 Php 在下面的 URL 中获取“posts-total”并将其回显。我该怎么做?
http://example.tumblr.com/api/read/json?num=0
谢谢
Update:
我尝试使用
$result = json_decode(file_get_contents('http://example.tumblr.com/api/read/json?num=0'));
$print_r($result);
echo $result[1];
我收到 500 错误。当我试图回显 $result 时,我什么也得不到。
【问题讨论】:
-
我打错字了-应该是 print_r- 这可能会引发您的 500 错误。问题是 url 返回一个带有 json 的变量,而不仅仅是一个纯 json
标签: php api file-get-contents tumblr